展开全部
getline会生成62616964757a686964616fe78988e69d8331333337616631一个包含一串从输入流读入的字符的字符串,直到以下情况发生会导致生成的此字符串结束。1)到文件结束,2)遇到函数的定界符,3)输入达到最大限度。
函数原型:
(1)istream& getline (istream& is, string& str, char delim);
(2)istream& getline (istream& is, string& str);
其中:delim 为终结符,第二种形式 delim默认为 '\n'(换行符)。
例子:(2)#include
#include
#include
using namespace std;
int main()
{
string buff;
ifstream infile;
ofstream outfile;
cout<
cin>>buff;
infile.open(buff.c_str());
if(!infile)
cout<
cout<
cin>>buff;
outfile.open(buff.c_str());
while(getline(infile, buff))
outfile<
infile.close();
outfile.close();
return 0;
}