以下是源代码:
#include<iostream>
#include<cstdlib>
#include<fstream>
#include<cstring>
using namespace std;
void test01()
{
ifstream ifs;
ifs.open("test.txt",ios::in);
if(!ifs.is_open()){
cout<<"打开失败"<<endl;
return;
}
//读数据
3.
string buf;
while(getline(ifs,buf))
{
cout<<buf<<endl;
}
ifs.close();
}
int main()
{
test01();
system("pause");
return 0;
}
getline有很多重载形式,你看提示那里 3/9左右有箭头,可以翻看别的形式
getline 是有多个重载的呀,而且那个不叫注释,而是语法提示。