I am trying to read data from a file and print it out the screen. I am trying to store the data that is read in to a struct. I feel like I am using either the wrong loop or I am not incrementing i the correct way. The data file is set up like so:
Zachary Law
1000
50
50
Bryan Law
1001
30
50
Lauren Keck
1002
20
50
When I run the program below I am getting the following output to my screen:
Zachary Law
1000
50
50
// This line being skipped
0
0
0
Thank you for the reply Miini, I had actually tried this earlier but accidentally used infile.ignore() since I was working from a file :p thanks I will test this out when I get home with cin.ignore()
Just an update to anyone struggling with this, infile.ignore() nor cin.ignore() solved my issue. I ended up just reading the name in separate
infile >> Fname;
infile >> Lname;
Sorry for that. It just a thorn in my side: no one ever in my memory used the way recommended in article. Everyone just use first introduced.
When you try something an it does not work, show what you did. You might make a mistake (if you want to use infile.ignore, you need to place it after line 34, for example)