Link to home
Start Free TrialLog in
Avatar of theotron5000
theotron5000

asked on

Problem with getline function reading from file

Here is the problem.  When I execute the code contained in the zip file at http://www.theotron5000.com/help.zip (my personal website) the text file is not parsed properly.  I use a series of nested loops to read in to a series of integers and character array variables (see source).  The parsing works properly after the first line; however, the first line is not read in entirely properly.

For instance, for the text files included in the .zip archive, the first two lines of text input are:

1,6,Uno Mas,1,iiii,1,jjjj,2,kkkk,,,,,,,,,,,,,,,,,1,mmmm
2,7,Jackson,2,iiii,4,jjjj,5,kkkk,,,,,,,,,,,,,,,,,6,mmmm


These result in the output of:

1,6,Uno Mas,1,,1,jjjj,2,kkkk,0,,0,,0,,0,,0,,0,,0,,0,,1,mmmm
2,7,Jackson,2,iiii,4,jjjj,5,kkkk,0,,0,,0,,0,,0,,0,,0,,0,,6,mmmm

NOTE: in the above output, the strin 'iiii' is missing from immediately after the '1' following 'Uno Mas'.  However, in the second line that string appears correctly.  Also, the text file being read is NationalReps.txt, the others may be ignored.

Why is this occurring?

Thanks for the help,
Theo Peterson
theo@iastate.edu
ASKER CERTIFIED SOLUTION
Avatar of efn
efn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of theotron5000
theotron5000

ASKER

I am a moron.  Thanks for pointing out the obvious error efn.