不懂求教
程序代码:
#include<iostream> #include<fstream> #include<vector> #include<string> #include<algorithm> #include<stdlib.h> using namespace std; vector<string> *tvec() { string filename; cout<<"please enter filename:"<<endl; cin>>filename; //open file ifstream infile(filename.c_str(),ios::in); //if(!filename) if(!infile.is_open()) { cout<<"unable to open the file "<<filename; exit(-1); } else cout<<"\n"; vector<string> *lines_of_text= new vector<string>; string textline; typedef pair<string::size_type,int> stats; stats maxline; int numline=0; while (getline(infile,textline,'\n')) { cout<<"lineread:"<<textline<<'\n'; if(maxline.first<textline.size()) //这里的maxline.first是什么意思啊?不明白 { maxline.first=textline.size(); maxline.second=numline; } lines_of_text->push_back(textline); ++numline; } return lines_of_text; } int main() { vector<string>* evec; evec=tvec(); return 0; }