#include "stdio.h"void main(void){ int a=10; int *p = &a; unsigned int b = (unsigned int)p; printf("0x%x\n",p); printf("0x%x\n",b); int *out = (int *)b; printf("0x%x\n", *out);} 很奇怪,只能打印前两个printf,最后一个
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 05:22:28
#include "stdio.h"void main(void){ int a=10; int *p = &a; unsigned int b = (unsigned int)p; printf("0x%x\n",p); printf("0x%x\n",b); int *out = (int *)b; printf("0x%x\n", *out);} 很奇怪,只能打印前两个printf,最后一个
#include "stdio.h"void main(void)
{
int a=10;
int *p = &a;
unsigned int b = (unsigned int)p;
printf("0x%x\n",p);
printf("0x%x\n",b);
int *out = (int *)b;
printf("0x%x\n", *out);
}
很奇怪,只能打印前两个printf,最后一个就提示Segmentation fault 错误.
高手们解答下吧.我是int指针赋值给unsigned int,然后把unsigned int里面的值赋值给int 指针,
然后*out就会提示这个错误,编译没有问题,执行的时候提示的
#include "stdio.h"void main(void){ int a=10; int *p = &a; unsigned int b = (unsigned int)p; printf("0x%x\n",p); printf("0x%x\n",b); int *out = (int *)b; printf("0x%x\n", *out);} 很奇怪,只能打印前两个printf,最后一个
这段代码应该可以运行通过,我在我的机器上运行通过了.最后一个printf打印的是a,也就是10进制的10