0
点赞
收藏
分享

微信扫一扫

回车与换行的区别

晴儿成长记 2022-01-27 阅读 112

回车与换行的区别

符号 ASCII码 意义

\n 10 换行

\r 13 回车CR

windows – 回车 == 先回车后换行

windows下的点一下回车,效果是:回车换行,就是\r\n

#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 << "end" ;
	return 0;
}

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-45su8uEG-1643246633594)(C:\Users\赵晓鹏\AppData\Roaming\Typora\typora-user-images\image-20220127091704381.png)]

Unix

unix系统下的回车一下就是一个\n

Mac

每行结尾是“<回车>”,即"\r"

举报

相关推荐

0 条评论