
February 18th, 2002, 04:15 AM
|
|
Junior Member
|
|
Join Date: Feb 2002
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
ifstream - text input into char and int
I'm having difficulty correctly parsing data from a text file. The text file is roughly divided into two colums. The first column contains a char, the second column an int. I defined a variable inFile as type ifstream. I can pull all the data line by line using:
while (getline(inFile, s))
Unfortunately, I don't have a clue as to how I can correctly extract the required information from this point.
I suppose its possible to pull the data one char at a time.
inFile >> chara >> intb;
Unfortunately, when I do this, my program spits out erroneous data.
Am I approaching this problem correctly or am I way off and there is a simpler, cleaner way to parse data from a text file? Any pointers would be helpful.
|