error on working with files
Hello guys. Sorry for disturbing but i do need some help.
I maked a simple program that reads from a file which looks like this:
Code:
#include <stdio.h>
int main(){
FILE *fin;
int var[10000][7],n,i,j;
if((fin=fopen("var.in","r+"))==NULL)
exit(1);
fscanf(fin,"%d",&n);
printf ("%d\n",n);
for(i=1;i<=n;i++){
for(j=1;j<7;j++){
fscanf(fin,"%d",((var+i)+j));
}
}
for(i=1;i<=n;i++){
for(j=1;j<7;j++){
printf("%d ",*(*(var+i)+j));
}
printf("\n");
}
return 0;
fclose(fin);
}
and the file var.in looks like this:
Code:
2
1 3 4 5 6 7
6 4 6 4 3 2
My program prints this:
Code:
2
0 0 0 0 0 0
0 0 0 0 0 0
Could anyone help me, and explain why is this happening? instead of that 0's should be the values on the second and third line of the file.
Thanks a lot!
Regards,
Victor