为什么这段代码中的getline用法跟他这个系统注释的不一样呢?
以下是源代码:
#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;
}