解析
第五题:
//What is the output of this C code?
#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf("x is %d", x);
}
sizeof 运算符只会得到大小,不会运算其中的表达式,所以x的值不变,仍为97。
第七题:
//What is the output of this C code?
#include <stdio.h>
void main()
{
int x = 4;
int *p = &x;
int *k = p++;
int r = p - k;
printf("%d", r);
}
将x的地址赋给了指针p,指针k是x的地址自增,地址是可运算的,因此p-k=1。