Hi. I’m reposting on here because I’m having a bit of trouble understanding some help I was given on the beginners forum. I'm having trouble being able to read in my input data to my code function from a file. I have it organized: last, first ID. I need to be able to later output it: ID First Last. I need to be able to erase the comma. I'm not quite sure what to put in my while loop. I think I'm supposed to use pos = str.find(',') and str.erase(pos, n) . Any help would be appreciated.
1 2 3 4 5 6 7 8 9 10
void readem()
{
int i;
ifstream inf("demo.dat");
i = 0;
while (!inf.eof())
{
//What goes here?
}
}
Here are some test names:
Cruz, Terry 340
Temple, Shirley 112
Armstrong, Lance 725
Fey, Tina 202
Yes. “How to remove a comma” is my question. I forgot to explicitly write that in. I know how to read in a data set without the comma—Being exactly what you did.
The aim is not to memorise every last detail, but enough to get a sense of the "lay of the land".
So whilst you might not remember the detail (that's what manual pages are for), you'll recall enough to remember that there was something that could be of use.
Along the way, you'll figure out a way to do what you want.