#include <stdio.h>
int main()
{
char* p1 = 1;
char* p2 = '1';
printf("p1 = %c\n", *p1); //段错误
printf("p2 = %c\n", *p2); //段错误
return 0;
}
//对应的汇编代码,可以看出这里的地址是0x1和0x31
char* p1 = 1;
80483cd: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp)
80483d4: 00
char* p2 = '1';
80483d5: c7 44 24 18 31 00 00 movl $0x31,0x18(%esp)
80483dc: 00