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++的换行符怎么用-创新互联
网页链接:https://www.cdcxhl.com/article24/diioce.html
成都网站建设公司_创新互联,为您提供做网站、Google、定制开发、ChatGPT、虚拟主机、小程序开发
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联