Dear All,
After spending a great deal of time searching previous posts, I am still stuck with the following. Essentially I am trying to open and read from a file, storing the file data into a struct. Please see below:
here is my struct declared in my header file....
now i need to open an existing file and read the data into the above struct. the file data is in the following format ...Code:typedef struct { int carsSold[MAX_BRANDS]; float carSaleValue; }CarSales;
20,20100.20
15,15100.50
.. and here is my code so far (not very far i know!)....
what would the best method be to read the file data and store it in the struct? any ideas would be appreciated!Code:FILE *fptr = NULL; CarSales s; int j; /* open car sales file for reading */ fptr = fopen("Sales.txt", "r"); /* check to see if car sales file opened succesfully */ if(fptr == NULL){ printf("Failed to open car sales file for reading.\n"); }
cheers,
dankas



LinkBack URL
About LinkBacks


