Single, double quotes and sizeof('a') in C/C++

后端 未结 2 1745
难免孤独
难免孤独 2021-01-31 07:25

I was looking at the question Single quotes vs. double quotes in C or C++. I couldn\'t completely understand the explanation given so I wrote a program:

#include         


        
相关标签:
2条回答
  • 2021-01-31 07:40

    because there is no char just intgers linked int a character

    like a is 62 i guess

    if you try printf("%c",62); you will see a character

    0 讨论(0)
  • 2021-01-31 07:51

    In C, character constants such as 'a' have type int, in C++ it's char.

    Regarding the last question, yes,

    char ch = 'a';
    

    causes an implicit conversion of the int to char.

    0 讨论(0)
提交回复
热议问题