Printing char by integer qualifier

后端 未结 4 1702
猫巷女王i
猫巷女王i 2020-12-20 17:15

I am trying to execute the below program.

#‎include‬ \"stdio.h\" 
#include \"string.h\" 

void main()
{ 
    char c=\'\\08\'; 
    printf(\"%d\",c); 
} 
         


        
4条回答
  •  太阳男子
    2020-12-20 17:30

    \0 is used to represent octal numbers in C/C++. Octal base numbers are from 0->7 so \08 is a multi-character constant, consisting of \0, the compiler interprets \08 as \0 + 8, which makes it '8' whose ascii value is 56 . Thats why you are getting 56 as output.

提交回复
热议问题