I have no idea how this would be done, but how would I check the amount of line that exist in a text file.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("example.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
system("pause");
return 0;
}
So this reads the text file. But lets say there are 2 lines;
HELLO
GOODBYE
This means there are 2 lines, so how would i be able to check how many lines exist?