working with fstream object, how to determine if there's more than 24 lines of data

Hi guys,
As always I greatly appreciate this site and all of you that help here.

I'm writing a program for class that's supposed to read and display data from a file, while pausing after 24 lines, every 24 lines. I know how to do all of that except pausing after 24 lines, every 24 lines lol. I mean I know that's not possible with a for loop and a counter.. or is it. Is there some sort of test like eof() in fstream that would tell me where we're at in the file? I dunno. My brain is tired. Can someone point me in the right direction?
Just increment a counter every line you read from the file, then when you get to 24, just pause however then keep going.
is there some way to loop that indefinitely based on multiples of 24 that my mathematically challenged brain isn't thinking of?
would something like if (counter%24 = 0) work? I haven't used the modulus operator much
nevermind think i got it!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void showFile(fstream &file)
{
	string line;
	int counter = 0;
	char ch;
	while(file >> line)
	{
		counter++;			
	
		while(counter % 24 == 0)	
		{
			cout << line <<endl;
			cout <<"Please press enter to continue";
			cin.get(ch);
			counter++;
		}
		cout << line << endl;
	}
	return;
}
Topic archived. No new replies allowed.