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

  • 相关阅读:
    [BJWC2010]外星联络
    [NOI2015]品酒大会
    工艺 /【模板】最小表示法
    [NOI2016]优秀的拆分
    [HEOI2016/TJOI2016]字符串
    [SDOI2016]生成魔咒
    【模板】后缀自动机 (SAM)【SA解法】
    [湖南集训]图森
    [USACO17DEC]Standing Out from the Herd P
    Annihilate
  • 原文地址:https://www.cnblogs.com/luckygxf/p/3977171.html
Copyright © 2011-2022 走看看