I'm having trouble getting the file I/O working in this little program. can anyone help?
thanks for anything in advance!
Code:#include <iostream> #include <fstream> #include <string> using namespace std; int main(int argc, char *argv[]) { string line; int counter = 0; ifstream myFile(argv[1]); if(myFile.is_open()) { while(! myFile.eof()) { getline(cin, line, '\n'); cout << line << endl; counter++; } myFile.close(); cout << "there were " << counter << " lines in the file \n"; } else cout << "unable to open file \n"; return 0; }