Counting the number of lines in a file

Hello, I was trying to make a function that would return how many lines are in a certain file. I was looking at
which talks about how to count how many characters are in a text file. I just want the number of lines with in a file. Can anyone help me?
Last edited on
While std::getline succeeds, add to the line count?
in a linear way, if your data is a specific fixed size per line then you count the number of chars (bytes) then increment if you reach the line length you need. Thats the best way I can think to do it. Or you could use a line terminator character if its a text file and check for that char, but that would waste space.
Topic archived. No new replies allowed.