:
: There are a batch of errors in the compiler, the code is from the
: book "c++ prime third edition.
:
hai,
your question is not clear about what the error you are getting. As per me the declaration of vector variables may be worngly declared. because syntax for declaring vector is ::
vector <data_type> name(desired_size);
ex:vector <car> parkingGarage(10);
so just check once and the link below will help you for your further rectificatio nof error
http://www.codeproject.com/Articles/38600/String-and-vector-manipulation-through-example-Mor
: #include <iostream> : #include <vector> : using namespace std; : int main(int arg, char*args[]) : { : istream&getline(istream&is,string str,char delimiter); : vector<string,allocator>*retrieve_text() : { : string file_name; : cout<<"please enter file name:"; : cin>>file_name; : ifstream infile(file_name.c_str(), ios::in); : if(!infile) : { : cerr<<"sorry,can't open the file"<<file_name<<endl; : exit(-1); : } : else cout<<endl; : vector<string,allocator>*line_of_text=new vector<string,allocator>; : string textline; : string texline; : typedef pair<string::size_type,int>stats; : stats maxline; : int linenum=0; : while(getline(infile,textline,'\n';)) : { : cout<<"line read:"<<textline.size()) : if(maxline.first<<textline.size()) : { : maxline.first=textline.size(); : maxline.second=lineum; : } : lines_of_text->push_back(textline); : lineum++; : } : return lines_of_text; : } : system("pause"); : return 0; : : }:
: There are a batch of errors in the compiler, the code is from the
: book "c++ prime third edition.
:
hai,
your question is not clear about what the error you are getting. As per me the declaration of vector variables may be worngly declared. because syntax for declaring vector is ::
vector <data_type> name(desired_size);
ex:vector <car> parkingGarage(10);
so just check once and the link below will help you for your further rectificatio nof error
http://www.codeproject.com/Articles/38600/String-and-vector-manipulation-through-example-Mor