了解 C 中的 sizeof 运算符

Understanding the sizeof operator in C

char c = 'A';
printf("%d\n",sizeof(c));// output = 1
printf("%d\n",sizeof('A')); // output = 4

为什么sizeof运算符对同一个字符给出不同的输出?请帮忙

cchar类型的变量;它的大小是 1 个字节。

'A' 是一个 int 字面量 - 不要问我为什么标准这么说。它的大小在您的平台上是 4 个字节(与 sizeof(1) 相同)。