I need to read in up to six text files from command line agruments. This is the code I have but it exits at the if(!fin) exit(1); line and I don't know why.
Code:#include <fstream> #include <iostream> #include <string> #include <vector> using namespace std; int main(int argc, char* argv[]) { vector<vector<string> > words; string word; int wordCount =0; cout<<"before loop"; for(int i=1; i < argc; i++) { ifstream fin(argv[i]); if(!fin) exit(1); cout<<"after loop"; wordCount =0; while(!fin.eof()) { fin>>word; cout<<word<< "-"; words[i][wordCount] = word; wordCount++; } } for(int i =0; i< words.size(); i++) for(int x=0; x< words[i].size(); x++) cout<< words[i][x] << " "; }



LinkBack URL
About LinkBacks


