Help with this program please

I have an assignment that needs me to read data from a file, i figured how to do it, however, when i add another name to the file, it just goes to ****...

here's the first file that i can read fine:
Mickey Mouse 45 78 91
Minnie Mouse 95 92 88
Donald Duck 72 81 89

now if i add a name everything gets messed up, for ex:

Mickey Mouse 45 78 91
Minnie Mouse 95 92 88
Random Name
Donald Duck 72 81 89

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  while (!fin.eof())
	{
		fin >> fname >> lname;
		fin >> a >> b >> c;

		if (fin.get() == '\n')
		{
			cout << fname << " " << lname << " " << a << " " << b << " " << c << " " << endl;

		}
		else
		{
			cout << fname << " " << lname << " " << a << " " << b << " " << c << " " << endl;
		}
	}


I know I'm missing something, but I can't quite get it. Any help would be appreciated.
Last edited on
Does Random Name have three numbers after it?
It doesn't in your example.

Line 4 is expecting 3 numbers. If there are not three numbers after Random Name, fin's bad bit will be set and subsequent input will fail.
Topic archived. No new replies allowed.