Hi ! I'm struggling this problem and I didn't find a solution for it.
I'm trying to read data from txt which the data of the txt file is about having size of matrix and coordination (x,y) according to the size where the value "1" located. it might have more than matrix on the same txt file. for example"
the size of the matrix is always signed as 3 digits,Code:444
12
23
33
555
12
23
33
44
for example in the first line of txt file there's 444, it says that the matrix size of matrix 4*4 and the value number one is located on matrix at coordination: 12 23 33
for second matrix which it's in size 5 as shown in fifth line in txt file 555, the value of number one in that matrix is located at coordination: 12 23 33 44 .
the output is to print all the matrixs that txt file input have with proper value as written in txt file.
I'm stuck in and not moving forward , How can I assign matrixs by coordination that are given in txt file? thanks alot!!
I've written this code for reading data from txt file but didn't work well!(wrong output)
Code:int main()
{
int i,j;
double value[10000][10000];
FILE *archivo;
archivo = fopen("matrix.txt","r");
if (archivo == NULL)
exit(1);
i=0;
while (feof(archivo) == 0)
{
fscanf( archivo, "%lf %lf %lf", &value[i][0],&value[i][1],&value[i][2]);
printf("%10.0f %f %f\n", value[i][0], value[i][1], value[i][2]);
i++;
}
printf("My matrix:\n");
for(j = 0; j < i; j++)
printf("%10.0f %10.3f %10.3f\n", value[j][0], value[j][1], value[j][2]);
fclose(archivo);
return 0;
}
THANKS for your help !