!将若干行不定常的字符串和换行号写入文件后,怎样在将这些串整行读出
求助!将若干行不定常的字符串和换行号写入文件后,怎样在将这些串整行读出?
如题
------解决方案--------------------
getline
------解决方案--------------------
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
string s;
ifstreamfin( "test.txt ");
while(getline(fin,s)) // 读一行,自动判断换行,丢弃换行符.
cout < <s < <endl; // 输出这一行
}
如题
------解决方案--------------------
getline
------解决方案--------------------
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
string s;
ifstreamfin( "test.txt ");
while(getline(fin,s)) // 读一行,自动判断换行,丢弃换行符.
cout < <s < <endl; // 输出这一行
}