Hello again. I'm having trouble with reading a file containing several different types of data(all part of a structure).
This is the contents of my .txt file
and this is my codeCode:253.99,4478,Video Card,1 88.99,7789,Motherboard,3 154.99,4753,CPU,2
I've tried several differen't ways of getting the data, but none of them seem to work for me. I want each part of the structure to be filled with the data until there's a comma(","). After the comma it moves on to the next part of the structure. When there's a new line, it moves to the next structure in the array.Code:Info p[MAX_NUM_PURCHASES]; fstream inDataFile; inDataFile.open(("C:\\" + yearMonth + ".txt").c_str(), ios::in); int numPrint = 0; for(int i = 0; i < 5; i++) { while(!inDataFile.eof()) { p[i].price = inDataFile.get(); p[i].serialNum = inDataFile.get(); p[i].descript = inDataFile.get(); p[i].order = inDataFile.get(); }//End while not end of file. numPrint++; }//!End of for loop
Does anybody have any ideas for this?



LinkBack URL
About LinkBacks


