c++文件输出的小问题 谢谢!
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
int main()
{
const int str_size=100;
int i=0;
vector<string> str(str_size);
string str_temp;
fstream iofile("data.txt");
if (!iofile)
cout<<"error";
else
{
while (iofile>>str_temp)
{
cout<<"successfuly read this line. "<<endl;
cout<<"this word is "<<str_temp<<endl<<endl;
str[i++]=str_temp;
}
}
cin>>i;
return 0;
}
==========================================
环境:Dev-C++ 4.9.8.0
比如data.txt里面的数据如下:"a hello world!" 运行结束后。
data.txt里面的数据就变成了:"aa hello world!" ,以后每执行一次就多一个a.
不知道什么问题,谢谢!动手太少,多多指教!