When I try to open a file it says it doesn't exist, but it really does though..
Reader( string fileToRead );
// To simplify the implementation, the user may either call "getLine" but
// not "hasAnotherOpenAngledBracket" and "getToken" OR
// call "hasAnotherOpenAngledBracket" and "getToken" but not "getLine".
// Reads the next input line and stores it in "line". It returns ture
// if "read" did not return eof. Otherwise, it returns false.
Code:#include<iostream> #include <string> #include "Reader.hpp" // Copy the contents of "inputFileName" to standard output. // This program demonstrates the use of "Reader" and its // function, "getLine". int main( int argc, char *argv[] ) { if ( argc != 2 ) { cout<< "usages: "<< argv[0] <<" <filename>\n\n"; exit(0); } Reader reader(argv[1]); return 0; }Code:#include <iostream> #include "Reader.hpp" #include <fstream> using namespace std; Reader::Reader( string fileToRead) { ifstream inFile; inFile.open("fileToRead"); if(!inFile.is_open()) { cout << "Error: " << fileToRead << " does not exitst!" << endl; exit(0); } inFile.close(); }



LinkBack URL
About LinkBacks


