all of the code works, apart from the fact that it keeps printing out the last character in the text file.Code:#include <iostream> #include <fstream> using namespace std; int main(int argc, char * argv[]) { if(argc<2) { cout<<"The correct format is file <string>"<<endl; return 0; } cout<<"correct number of parimeters."<<endl; cout<<"You have "<<argc<<" parimeter"<<endl; for(int x=0;x<argc;x++) { cout<<argv[x]<<endl; } if(argc>2) { if(argv[1]="open") { ifstream a_file; a_file.open(argv[2]); char x; a_file.get(x); while(x!=EOF) { cout<<x; a_file.get(x); } a_file.close(); } } return 0; }




Reply With Quote