c++getline的用法

2025-04-23 18:18:04
推荐回答(2个)
回答1:

#incluude
#include
#include

using namespace std;
int main()
{
ifstream in("input.txt");
if(!in)
{
cerr << "some errors happened";
return -1;
}
string str;
while(getline(in, str))
{
cout << str << endl;
}
return 0;
}

回答2:

while(!headFile.eof())
{
getline(headFile,sline,'\n');
cout<<"Read one line:"< }