How to read the number of lines from a text file?

For example, A file have lots of lines and each lines resemble one "record".
So u choose this option of viewing data of file.

When u select this option, the menu will prompt u to enter file name,
This is when the user enter the name of the file and upon that action,
The program will read from the file as specified.

I end up coding some garbage like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
       
string filename;
string storeFile;
cout<<"Please enter filename: ";
getline(cin, filename);
       
ifstream file(filename);
if(file.is_open())
{
getline(file, storeFile);
......
.........
............
Do you want a line count or a specific line from the file?
A line count.. After it reads into the text-file. On the menu, it should cout the number of lines it have.
For example, "4 records have been noted!" or something like that..
Topic archived. No new replies allowed.