64,637
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main(void)
{
printf("sizeof(void *)=%d\n", (int)sizeof(void *));
printf("sizeof(unsigned int)=%d\n", (int)sizeof(unsigned int));
return 0;
}
$ make sizeof_ptr && ./sizeof_ptr
cc -O2 -fno-strict-aliasing -pipe sizeof_ptr.c -o sizeof_ptr
sizeof(void *)=8
sizeof(unsigned int)=4
$ uname -a
FreeBSD freebsd.unix-center.net 7.2-RELEASE-p8 FreeBSD 7.2-RELEASE-p8 #0: Tue May 25 17:51:43 UTC 2010 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
#include <stdio.h>
struct node
{
float a;
int b;
int c;
};
int main()
{
struct node s=
{
3,
5,
6
};
struct node *pt=&s;
printf("%f\n", *(float*)pt);
printf("%d\n", *(int*)pt);
return 0;
}