您的位置:首页 > 编程语言 > C语言/C++

c++在txt中每行写入数据和每行输出

2015-10-11 16:34 211 查看
<span style="font-size:18px;">#include<iostream>
#include<fstream>
#include<iostream>
#include<string>
using namespace std;

int main(){

// 定义输入文件流类对象infile

string filename = "E:data1.txt";
//ofstream outFile(filename.c_str(), ios::app);  //在文件末尾写入
//for (int r = 0; r<800; r++)
//{
//	outFile << "E:/图像/第" << r << "个图像.jpg" << endl;
//}
ifstream  file("E:data1.txt");
char data[100];

while (!file.eof())
{
file.getline(data, 100);
cout << data << endl;
}
file.close();
system("pause");
return 1;
}</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: