<分区>
我写了关于 sizeof
运算符的代码。如果我这样写:
#include <stdio.h>
int main() {
char a[20];
printf("%zu\n", sizeof(a));
return 0;
}
输出:
20 // Ok, it's fine
但是,如果我像这样使用逗号运算符:
#include <stdio.h>
int main() {
char a[20];
char b;
printf("%zu\n", sizeof(b, a));
return 0;
}
输出:
8 // Why the output 8?
所以,我有一个问题:
- 为什么编译器在第二个例子中给出输出
8
? - 将
comma
运算符转换为sizeof()
运算符的行为是什么?