C language sizeof(char)

Hello , I compiled the following code with gnu C compiler.

1
2
3
4
5
6
7
#include <stdio.h>
int main(void)
{
    char ch = 'A';
    printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f));
    return 0;
}


Output : 1,4,4

is 'A' treated as an integer type instead of char ?
Last edited on
In C, 'A' is an int, not a char, yes.
In C++, it is a char, though. It's one of the many small differences between things that look the same in these languages.
Last edited on
thanks
Topic archived. No new replies allowed.