I used the following code in Code::Blocks IDE. I get the number of lines as 2. Kindly help me with the code.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream in("readInt.txt", ios::in);
if(!in)
{
cout << "Cannot open file";
return 1;
}
string str;
int j=0;
while(in)
{
getline(in,str);
j++;
}
cout << "No of lines are: " << j;
in.close();
return 0;
}