ends与 endl的区别?
ends与 endl的区别?
ends函数 终止字符串
endl 函数 终止一行并刷新缓冲区
#include <iostream>
int main()
{
using namespace std;
cout << "a" ;
cout << "b" <<ends;
cout << "c" <<endl;
cout << "e" << flush;
cout << "f" << flush;
cout << "g" ;
cout << "h" <<ends;
cout << "i" << flush;
cout << "j" <<endl;
return 0;
}
结果
ab c
efgh ij