习题8.10 读取文件中的每个单词存放到vector中

#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	ifstream input;
	input.open("data.txt");
	if(!input)
	{
		cerr<<"error";
		return 1;
	}

	vector<string> vecstr;
	string str;
	while(input>>str)
	{
		vecstr.push_back(str);
	}
}

  

posted on 2011-12-03 19:16  york_software123  阅读(198)  评论(0编辑  收藏  举报

导航