I have a text file containing datas that I want to read and store in a C structure. But this file can be different with a variable number of columns and rows, depending on the case being treated.
For example in one case we have this file (3 columns, 4 rows) :
56.3 1.8 25.9
-8.0 3.2 156.7
-9.4 -12.36 -11.8
-0.27 -0.04 0.1004
And in an other case we could have (2 columns, 5 rows) :
2.3 65.7
-8.2 3.4
9.4 -12.76
-0.27 -0.04
0.56 45.8
I can't use fscanf because I don't know at each cases the number of datas I will read. With fgets I can't access to each datas separately. For example I would like to store datas like this : datas[0][0] = line[0];
Do you have any idea to perform a such reading in C ?