#include<iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
int fileToVector(string fileName ,vector<string>& svec){
ifstream inFile(fileName.c_str());
if(!inFile)
return 1;
string s;
while (inFile >> s)
svec.push_back(s);
inFile.close();
if (inFile.bad())
return 2;
if(inFile.eof())
return 4;
if(inFile.fail())
return 3;
}
int main(){
vector<string> svec;
string fileName;
cout<<"Enter fileName:"<<endl;
cin>>fileName;
switch(fileToVector(fileName,svec)){
case 1:
cout<<"error,cannot open the file"<<fileName<<endl;
return -1;
case 2:
cout<<"system error!"<<endl;
return -1;
case 3:
cout<<"read error!"<<endl;
return -1;
}
for(vector<string>::iterator iter = svec.begin();iter!=svec.end();++iter)
cout<<*iter<<" ";
return 0;
}