Hi...
I've been trying to make a program where the input is txt file, and the output will be saved in txt file. But, I keep getting error Message.
My code looks like this:
#include <stdlib.h>
#include <stdio.h>
int main (){
int i,j;
float H [100][100];
FILE*in;
in=fopen("0.txt","rt");
FILE*out;
out=fopen("rotation0.txt","w");
if(in){
for(i=0;i<100;i++)
for(j=0;j<100;j++)
fscanf(in, "%f", &H[i][j]);
for(i=0;i<100;i++){
for(j=0;j<100;j++)
//printf("%d "H[i][j]);
printf("");;
}
}
else {
fprintf(stderr,"Cannot open file\n");
return 1;
}
for(i=0;i<100;i++){
for(j=0;j<100;j++){
printf("[%d][%d]=%f\n ",i,j,H[i][j]);
fprintf(out,"[%d][%d]=%f\n ",i,j,H[i][j]);
}
}
return 0;
fclose(in);
fclose (out);
}
The message says:
"parse error before *"
" "out" undeclared"
I found a couple strange things; if I move FILE*in below FILE*out, the error became:" "in" undeclared". And if I use different compiler (I'm using cygwin currently), it works. unfortunately, I can't use the other compiler because it doesn't work if increase the size of array.
Could you tell me, what's wrong with my code?
Thank you