我有像 12、13 这样的值,我想将它们分配给单个整数示例 k。我尝试了以下程序,但没有得到预期的结果。
enter code here
#include <stdio.h>
int main()
{
int k = 0;
printf("k address is %u\n", &k);
char* a = &k;
printf("%u\n", a);
*(a) = 12;
a++;
printf("%u\n", a);
*(a) = 13;
printf("k is %d\n",k);
return 0;
}
输出是:
k address is 3213474664
3213474664
3213474665
k is 3340