Help filling a structure with data from a file.
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 code
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.
inDataFile.open(("C:\\" + yearMonth + ".txt").c_str(), ios::in);
int numPrint = 0;
for(int i = 0; i < 5; i++)
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.
}//!End of for loop
Does anybody have any ideas for this?