I have a program that has an array of structs. I want to read a file which can look something like this:
Now i want to read these files into the array of structs but after searching and looking in my book i cant find an example of how this can be done. Below is the code slightly modified.Code:one two three four five
i have commented a line out so it will compile, what i have here is my best attempt at getting this to work, i only wish to read one line at a time, then assign it to a variable in the array, im also not sure if i can do this directly or i may need a temporary variable. cheers.Code:void ReadFile() { ofstream PetFile; PetFile.open ("test.txt"); if ( !PetFile.good() ) { cerr << "An error occured while opening pet data base." << endl; exit (1); } int PetIndex = 0; while ( !PetFile.eof() ) { //getline(PetFile, PetID[PetIndex].Status); cout << PetID[PetIndex].Status; //system("PAUSE"); ++NumRecords; cout << NumRecords; ++Index; cout << Index; //system("PAUSE"); } }
I get this error msg when the getline function is not commented.
47 no matching function for call to `getline(std:fstream&, eStatus&)'



LinkBack URL
About LinkBacks
fstream&, eStatus&)' 


