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.
不知道什么问题,谢谢!动手太少,多多指教!
#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.
不知道什么问题,谢谢!动手太少,多多指教!
...全文
相关推荐
LOG4CPP多个日志文件
LOG4CPP 支持多个文件,DEBUG/NOTICE/WARNING/ERROR/CRITICAL分别打到不同的文件
CPP-Exercises:CPP课程练习
CPP-Exercises:CPP课程练习
cpp.zip_数据结构_Visual_C++_
c语言实现任意数阶乘,具体信息请看源码。。。。。。。。。。
LIS.cpp.tar.gz_Help!_LIS acm_lis
ACM LIS.cpp help you to let UVa Judge to accept your code
cpp.rar_cpp106com_cpp699com_visual c
最基础的c++作业小程序,求和,阶乘,最大公约数等等等等


