0x0A和0x0D

这里主要是在windows下面做的小实验,linux没有试

先贴源码

 1 #include <iostream>
 2 #include <string>
 3 #include <stdlib.h>
 4 #include <stdio.h>
 5 
 6 
 7 #include "header3.h"
 8 
 9 using namespace std;
10 void swap(int&, int&);
11 //void swap(int, int);
12 
13 int main(){
14     printf("0x0A");
15     printf("%c", 0x0A);
16 
17     printf("0x0D");
18 
19 
20     return 0;
21 }

这里可以看出0x0A起到了换行,并将光标移动到行首的作用

okay,我们换一下代码

 1 #include <iostream>
 2 #include <string>
 3 #include <stdlib.h>
 4 #include <stdio.h>
 5 
 6 
 7 #include "header3.h"
 8 
 9 using namespace std;
10 void swap(int&, int&);
11 //void swap(int, int);
12 
13 int main(){
14     printf("0x0A");
15     printf("%c", 0x0D);
16 
17     printf("0x0D");
18 
19     return 0;
20 }

这里将0x0a换成了0x0d,这里只是输出了0x0D,可以看出第一次输出的0X0A被后面的0X0D覆盖了(可以只输出0Xd看以看到是被覆盖掉)。

 

所以0x0a是起到换行和将光标移动到行首的作用

0x0d起到将光标移动到行首的作用

ps:这里代码有点杂,在VC6.0中EOF = -1;NULL = 0

转载于:https://www.cnblogs.com/luckygxf/p/3977171.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值