#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