char filename[256];
scanf("%s", filename);
FILE *file = fopen(filename, "r");
int M, N, C, i, j, P, G;
fscanf(file, "%d", &M);
fscanf(file, "%d", &N);
fscanf(file, "%d", &C);
int xv[M + 1], yv[M + 1], h[M + 1]; // line 21
for (i = 1; i <= M; i++) {
fscanf(file, "%d", &xv[i]);
fscanf(file, "%d", &yv[i]);
fscanf(file, "%d", &h[i]);
}
Compiler VC 2017 return error:
error C2131: expression did not evaluate to a constant
note: fault caused by a reading of a variable out of its lifetime
note: see use of "%*"
Why this error appears in VS 2017 and when I use the Dev-C++ IDE it does not give an error and it executes correctly?