在c++中如果使用输入\输出符endl。请详细说明一下endl的用法。

来源:百度知道 编辑:UC知道 时间:2024/05/12 12:39:55
比喻在语句 :cout<<"the id is"<<endl <<2;
cout<<"the id is"<<i << endl;
上面2句endl的位置都不同,请说明一下何解!

endl就相当于输出的时候回车。
第一句的输出是the id is
2
第二句的输出是the id is i
然后光标到了第二行。

endl 表示把所有缓存输出,并换行

位置不同,只是表示换行的位置不同而已

huan hang