读书人

!将若干行不定常的字符串和换行号写入

发布时间: 2012-02-05 12:07:15 作者: rapoo

求助!将若干行不定常的字符串和换行号写入文件后,怎样在将这些串整行读出?

如题

[解决办法]
getline
[解决办法]
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
string s;
ifstreamfin( "test.txt ");
while(getline(fin,s)) // 读一行,自动判断换行,丢弃换行符.
cout < <s < <endl; // 输出这一行
}

读书人网 >C++

热点推荐