So i have this error:
Error 3 error C2143: syntax error : missing \';\' before \'type\' g:\\lel\\tommy\\tommy\\tommy.c 34 tommy
Are you compiling with c99 or c89?
The error appears to be because you are defining a variable within the body of the function (allowed in c99 not c89). Move double *ptr
to the beginning of the function and then just assign ptr = mat->matrix;
where the error now is.
When compiling a C program, MSVC doesn't allow declarations to follow statements in a block (it uses old C90 rules - support for declarations mixed with statements was added to C in the 1999 standard).
Move the declaration of double *ptr
to the top of matrix_read()
:
int matrix_read(struct matrep *mat, const char *filename)
{
FILE *fptr;
unsigned m, n;
double *ptr = NULL;
// ...
ptr = mat->matrix; //this is where the error used to occur
// ...
}
I really wish MS would implement this 'extension' to their C compiler.