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
0 0 83 0 0 0 0 0 0 90 0 0
0 0 83 83 0 0 0 0 0 0 0 0
0 0 0 0 0 0 90 0 0 0 0 0
0 0 0 0 0 90 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
4 3 2 1 1 2 0
My big problem is, it wont read the 0,0 part of the matrix as anything else but zero. No matter what number I put there, it always reads zero. I am sure there is not a problem with my addlevel(bla,bla) function since I can fix the matrix value of level[0][0], and info[0][0] right before the function and it will load up fine.
Has anyone else had problems with fscanf? If theres something wrong with my code, id like to know, but I personally dont see a single logical error. And get this, before I added the extra line of variables it only used to not read level0,0 and read info 0,0 JUST FINE!
- Code:
int status=0;
int x=0,y=0;
FILE *input;
input=fopen(temp,"r");//r
if(!input)
{
fclose(input);
}
else{
while(status!=EOF)
{
for(x=0;x<12;x++)
{
for(y=0;y<12;y++)
{
if(status==EOF)
{return;}
else{status=fscanf( input, "%i", &level[x][y]);}
}
}
for(x=0;x<12;x++)
{
for(y=0;y<12;y++)
{
if(status==EOF)
{return;}
else{status=fscanf( input, "%i", &info[x][y]);}
}
}
for(int i=0;i<4;i++)
{
status=fscanf( input, "%i", &arrowlist[i]);
if(status==EOF){return;}
}
if(status==EOF){return;}
status=fscanf( input, "%i", &min);
if(status==EOF){return;}
status=fscanf( input, "%i", &sec);
if(status==EOF){return;}
status=fscanf( input, "%i", &cows);
//level[0][0]=5;
addlevel(level,info,arrowlist,min,sec,cows);
}
fclose(input);
}
And heres the file that I write but it wont read correctly:
5 3 3 3 3 3 3 3 3 3 3 7
1 5 7 5 7 5 7 5 7 5 7 2
5 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
8 8 6 8 6 8 6 8 6 4 4 6
8 4 4 4 4 4 4 4 4 4 4 6
100 20 0 20 0 20 0 20 0 20 0 20
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 82 0 82 0 82 0 82 0 82 0 0
0 82 0 82 0 82 0 82 0 82 0 0
0 82 0 82 0 82 0 82 0 82 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
20 0 20 0 20 0 20 0 20 0 20 0
4 3 2 1 1 2 0
5 3 3 3 3 3 3 3 3 3 3 7
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
1 0 0 0 0 0 0 0 0 0 0 2
8 4 4 4 4 4 4 4 4 4 4 6
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 83 0 0 0 0 0 0 90 0 0
0 0 83 83 0 0 0 0 0 0 0 0
0 0 0 0 0 0 90 0 0 0 0 0
0 0 0 0 0 90 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
4 3 2 1 1 2 0
My big problem is, it wont read the 0,0 part of the matrix as anything else but zero. No matter what number I put there, it always reads zero. I am sure there is not a problem with my addlevel(bla,bla) function since I can fix the matrix value of level[0][0], and info[0][0] right before the function and it will load up fine.
Has anyone else had problems with fscanf? If theres something wrong with my code, id like to know, but I personally dont see a single logical error. And get this, before I added the extra line of variables it only used to not read level0,0 and read info 0,0 JUST FINE!