C++读取TXT的换行问题
原TXT文件中有较多的回车换行,但用C++打开时都没了,变成一段了,求解,如何才能保留原格式,代码如下#include<iostream>#include<fstream...
原TXT文件中有较多的回车换行,但用C++打开时都没了,变成一段了,求解,如何才能保留原格式,代码如下
#include<iostream>
#include<fstream>
using namespace std;
void main()
{
fstream out1;
char line[100];
out1.open("C:\\Users\\Administrator\\Desktop\\新建文件夹\\missionsix.txt",ios::in);
if (!out1)
{
cout << "error:unable to open output file!" << endl;
abort();
}
while(!out1.eof())
{
out1.getline(line,sizeof(line));
cout << line;
}
cout<<endl;
} 展开
#include<iostream>
#include<fstream>
using namespace std;
void main()
{
fstream out1;
char line[100];
out1.open("C:\\Users\\Administrator\\Desktop\\新建文件夹\\missionsix.txt",ios::in);
if (!out1)
{
cout << "error:unable to open output file!" << endl;
abort();
}
while(!out1.eof())
{
out1.getline(line,sizeof(line));
cout << line;
}
cout<<endl;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询