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:
The error message says:
"parse error before *"
" "out" undeclared"
I found a couple strange things; if I move FILE*in (line 8&9) below FILE*out (line 10&11), 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 I increase the size of array.
Could you help me, please?
Thank you
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:
Code:
#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);
}
"parse error before *"
" "out" undeclared"
I found a couple strange things; if I move FILE*in (line 8&9) below FILE*out (line 10&11), 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 I increase the size of array.
Could you help me, please?
Thank you
Comment