#include <iostream> #include <string> #include <fstream> using namespace std; bool processFile(const char *filename){ ifstream reader(filename); if( !reader ) return false; string line; while( true ){ getline(reader,line); if( !reader.eof() ){ cout << line << endl; }else{ break; } } reader.close(); return true; } int main(int argc, const char **argv){ processFile(argv[1]); return 0; }
c++ -o readfile readfile.cpp