代码如下
#include<stdio.h>
int main(void)
{
putchar('\0');
return 0;
}
求教各位大神,为什么结果会那么奇怪?我私下试过了,为什么putchar('0')会显示a呢?就这一点很奇怪,其他的都正常,请问大神,难道是我的运行库出问题了?本人小白,研究了2天都没想明白,求高人
PHP中文网2017-04-17 15:25:22
It should be a problem with your environment. I tested it on dev c++ and it worked fine
高洛峰2017-04-17 15:25:22
I have no problem in my compiler (gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)). Is the code in your screenshot putchar('0'); or putchar("0") ;?
大家讲道理2017-04-17 15:25:22
putchar outputs a character, puts outputs a string, encounter
The parameter in putchar must use single quotes '0'. If you use double quotes "0", the compiler will randomly output a character