The fgets() function reads a line of data from a file into a buffer. The sscanf() function extracts values from a buffer and puts them in variables based on a format string.
So if we have a file looking like this:
we might write code like this:
1.345, 34.527, 54.9
56.988, 0.7, 397.0
If you want further help, could you provide a sample of the data and post the code that you have written and details on why it is not working?
while (fgets(...)) /* Read a line of text from the file. */
/* Extract the float values and put them in an array. */
sscanf(buf, "%f, %f, %f", &floatarr, &floatarr, &floatarr);