2011-03-19 00:28:14|?次阅读|上传:wustguangh【已有?条评论】发表评论
13.写出运行结果:
{// test1 char str[] = "world"; cout << sizeof(str) << ": "; char *p = str; cout << sizeof(p) << ": "; char i = 10; cout << sizeof(i) << ": "; void *pp = malloc(10); cout << sizeof(p) << endl; }
6:4:1:4
---------------------------------------------------------------------
14.写出运行结果:
{// test2 union V { struct X { unsigned char s1:2; unsigned char s2:3; unsigned char s3:3; } x; ;unsigned char c; } v; v.c = 100; printf("%d", v.x.s3); }
3
---------------------------------------------------------------------
15.用C++写个程序,如何判断一个操作系统是16位还是32位的?不能用sizeof()函数
A1:
16位的系统下,
int i = 65536;
cout << i; // 输出0;
int i = 65535;
cout << i; // 输出-1;