#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string line; int count = 0; ifstream FileName (“try.txt”); if (FileName.is_open() && !FileName.eof()){ while (getline(FileName,line)){ count++; } } else cout << “Error opening file!” << endl; cout << “The number of lines in the file is ” << count << endl; system(“pause”); } This program counts the number of lines in a text file. I used the getline function to count it. The getline function is used to

Continue Reading