• 技术文章 >后端开发 >C#.Net教程

    c++换行符有哪些

    angryTomangryTom2019-11-04 15:22:50原创9307

    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语言教程

    以上就是c++换行符有哪些的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:c++ 换行符
    上一篇:c语言是一种什么编译形式的语言 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • PHP PHP_EOL 换行符• notepad换行符怎么去掉• php中换行符有哪些?• html换行符
    1/1

    PHP中文网