I have a file I read , and I want to start by counting the number of lines, so I did
I want to count the number of lines in a input file
void foo(ifstream &MyList)
{
int nb_lines = 0;
string line;
for (nb_lines; getline(MyList,line); nb_lines++) {};
[...]
}
Which is I guess not the right way to do it, but it does the work. How should I have done ?
In addition, compiler tells me that statement has no effect
, which is false (value of nb_lines is changed). Can I make him understand that? ---> just use for (; getline(MyList,line); nb_lines++) {};