c++换行符有哪些

c++换行符有哪些

\n 换行,光标移到下一行的开头;

endl,把缓冲槽的内容输出到控制台;

\r 回车,光标移到当前行的开头,不会换到下一行,如果接着输出的话,本行以前的内容会被逐一覆盖;

#include <iostream>
using namespace std;    
int main()  
{  
    cout << this is the first line\n;  
    cout << this is the second line\r;  
    cout << this is the third line\n;  
    cout << this is the fouth line\r;  
    cout << this is the fifth line\n; 
    cout<<First<<\n<<Second<<endl; 
    cout<<First123<<\r<<Second<<endl;  
    cout<<这是换<<endl<<行符;
    return 0;  
}

结果:

this is the first line
this is the third linee
this is the fifth line
First
Second
Second23
这是换
行符
Presss any key to continue

推荐课程:C语言教程

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...