I want to write a function that creates arrays of integers in a file with comma separated numbers like this:
1, 54520.00000, 86397.00000, 0 2, 54440.00000, 87200.00000, 0 3, 51280.00000, 97600.00000, 0 4, 50000.00000, 100000.00000, 0 5, 48880.00000, 100000.00000, 0
The first column is the number of each row, so the data I need is actually the next three columns.
My problems are:
Thanks for your help in advance!
you can use fscanf()
use the following fscanf()
into a loop till you reach the end of the file:
int i,j
double x,y;
while (fscanf(fp, " %d , %f , %f , %d", &i, &x, &y, &j) != EOF) {....}