123456789101112131415161718192021
#include <iostream> #include <fstream> using namespace std; int main(int argc, char *argv[]) { if(argc == 0) { cout << "Expected argument. Terminating.\n"; return 1; } ifstream ftbc(argv[0]); string thestr; int counted = 0; while( !ftbc.eof() ) { getline(ftbc, thestr); counted++; } cout << counted << "lines in file\n"; }