ifstream inFile;
inFile.open(filename); //open the input file
stringstream strStream;
strStream << inFile.rdbuf(); //read the file
string str = strStream.str(); //str holds the content of the file
I am using this code to read from a file. I need to get the number of lines at that file. Is there a way of doing that without reading the file second time?