Quantcast
Channel: 'THE ERROR IN THE VECTOR STRING' Thread RSS Feed
Viewing all articles
Browse latest Browse all 3

THE ERROR IN THE VECTOR STRING

$
0
0
#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.

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images