为什么不同编译器的ascii值有差异

Why there is difference in ascii values of different compiler

本文关键字:ascii 编译器 为什么不      更新时间:2023-10-16

代码在gcc和turbo c编译器中给出不同的输出。为什么这些编译器的ascii值之间存在差异?

#include <stdio.h>

int main()
{
int n=1;
while (n<70){
printf("Ascii value is %cn",n);
n++;
}
return 0;
}

上面的程序给出了不同的值输出,比如从1到16,或者类似于gcc和turbo c中的输出。为什么会这样呢?

不是编译器,而是控制台以不同的方式显示这些符号(前32个字符是不可打印的)。但是,字形32到126在所有情况下都保证相同。