Stuck in an infinite loop

I'm learning about filestreams and I used the example given in the tutorials.
the problem is I get stuck in an infinite loop in my while statement.

1
2
3
4
5
6
7
8
9
10
11
12
ifstream nFile("names.txt");
		
	if(nFile.is_open())
	{
		while(! nFile.eof() );
		{
			getline(nFile,name[num]);
			num++;
			
		}
		nFile.close();
	}


How do I escape the loop?
You should not put a ; after while.
ZOMg, I'm so Blind XD. Thank you.
You should never use eof() as the sole condition for your loop. Use the stream instead:

1
2
3
4
while(getline(nFile,name[num]));
	{
		num++;			
	}


For an explanation, read http://www.cplusplus.com/forum/general/24288/
Topic archived. No new replies allowed.