zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    [转]趣题:一个n位数平均有多少个单调区间?---- From Matrix67
    2015编程之美复赛
    Codeforces Round #304 (Div. 2)
    HDU 5226
    HDU 5225
    HDU 3666
    HDU 4598
    Codeforces Round #303 (Div. 2) E
    编程之美初赛第二场AB
    2015 编程之美初赛第一场 AC题
  • 原文地址:https://www.cnblogs.com/luckygxf/p/3977171.html
Copyright © 2011-2022 走看看