Reading different data from a textfile delimited with semicolons in C.
- by Chris_45
How do one read different records of data that are separated with semicolons into an array in C?
from textfile: Text One; 12.25; Text Two; 5; Text Three; 1.253
fopen ...
for(i = 0; i < nrRecords; i++) {
fscanf(myFile, " %[^;];", myRecords[i].firstText); /* Ok first text*/
fscanf(myFile, "%lf", &myRecords[i].myDouble1); /* But goes wrong with first double */
fscanf(myFile, " %[^;];", myRecords[i].secondText);
fscanf(myFile, "%d", &myRecords[i].myInt1);
fscanf(myFile, " %[^;];", myRecords[i].thirdText);
fscanf(myFile, "%lf",&myRecords[i].myDouble2);
}
fclose...