- UID
- 2198
注册时间2005-6-29
阅读权限255
最后登录1970-1-1
副坛主
该用户从未签到
|
#include <iOStream>
using namespace std;
struct stud
{
long num;
char *name;
float score;
};
int main()
{
struct stud wang={1000,"wangxiaoming",99.9};
struct stud *p=&wang;
/*int a;
int *p=&a;*/
printf("%ld %s %f \n",wang.num,wang.name,wang.score);
printf("%d \n",sizeof(*p)); // 12个字节
printf("%d \n",sizeof(wang));
printf("%0x \n",*p); // 输出了wang.num的十六进制 (只输出4个字节)
printf("%0x \n",wang); // 输出了wang.num的十六进制 (只输出4个字节)
printf("%0x %0x %0x \n",*p,*p,*p);
printf("%0x %0x %0x \n",wang,wang,wang);
printf("%0x %0x %0x %0x %0x %0x \n",wang,wang,wang,wang,wang,wang);
printf("%0x %0x %0x\n",*p,(*p).num,(*p).name);
printf("%0x %0x %0x %0x\n",*p,*p,(*p).num,(*p).name);
printf("%0x %0x %0x\n",wang,wang.num,wang.name);
printf("%0x %0x %0x %0x\n",wang,wang,wang.num,wang.name);
return 0;
}
非常有趣的运行结果:
1000 wangxiaoming 99.900002
12
12
3e8
3e8
3e8 432090 42c7cccd
3e8 432090 42c7cccd
3e8 432090 42c7cccd 3e8 432090 42c7cccd
3e8 432090 42c7cccd
3e8 432090 42c7cccd 3e8
3e8 432090 42c7cccd
3e8 432090 42c7cccd 3e8
Press any key to continue |
|