Hello there,
I had this code working yesterday, but it seems like I edited it a bit and lost the working version. I cant get this to work anymore.
I basically want to scan a matrix from a .txt file. But each time it scans the first row, the second one is skipped, and it reads the third instead :(
Here is my code :
for(i=0;i<=test->rowmat1;i++){
for(j=0;j<=test->colmat1;j++){
fscanf(fin,"%f\t",&test->mat[i][j]);
}
fscanf(fin,"%*[^\n]",&test->mat[i][j]);
}
For example, for a matrix of :
1.00 2.00 3.00
4.00 5.00 6.00
7.00 8.00 9.00
10.00 11.00 12.00
If I extract 3 rows and 3 cols, I get :
1.00 2.00 3.00
7.00 8.00 9.00
Then fails, it wants to skip over the second line but there is nothing after 10 11 12
Why did it stop working ? What do I have wrong ?
@Derek: removing the second scanf, I get for extracting 3 by 3 matrix
1.00 2.00 3.00
4.00 5.00 6.00
7.00 8.00 9.00
10.00 11.00 12.00
1.00 2.00 3.00
5.00 6.00 7.00
9.00 10.00 11.00
Last digit is skipped :S
Please help, Thanks in advance.