Hi everyone, Im trying to find some help with some C file i/o stuff that I cant really figure out. I'm not trying to mooch off work from people as most boards dont like, but on my other forum no one can really help me it seems.
Anyways, if anyone wants to help I have a file called "cars.dat" and im trying to take the data from there and assign it to variables, thats my only problem, because it doesnt seem to be working. Heres the .dat code...
John Jones 55 250 20
Mary James 67 350 10
Amy Smith 99 100 8
Joe Johns 88 123 86
Trudy Mains 56 1000 80
Mary Ames 97 238 15
And here is how I am assigning it to variables, where Im guessing where my problem is...
for (i=0; i<MAXNUM; i++)
fscanf(fp, "%s", &fName[i]);
fscanf(fp, "%s", &lName[i]);
fscanf(fp, "%d", &carNum[i]);
fscanf(fp, "%d", &milesDriven[i]);
fscanf(fp, "%d", &usedGallons[i]);
If anyone could help me out it would be greatly appreciated.