Posted on 2009-10-28 00:18
小蘇 閱讀(807)
評論(0) 編輯 收藏 引用
1、下題的輸出是什么?
typedef struct
{
int num;
char name[10];
int age;
}Student,*pStudent;
void printName(pStudent pt)
{
printf("%s\n",pt->name);
return;
}
void main()
{
Student students[3]={{111, "liu", 18},
{222, "wang", 19},
{333, "zhao", 10}};
printName(students+2);
return;
}
2、選擇
#include <stdio.h>
void main()
{
union
{
int k;
char i[2];
}*s, a;
s=&a;
s->i[0]=0x39;
s->i[1]=0x38;
printf("%x\n", a.k);
}
A.3839 B.3938 C.380039 D.不可預(yù)知
3、
enum ENUM_A
{
X1,
Y1,
Z1=6,
A1,
B1
};
enum ENUM_A enumA=Y1;
enum ENUM_A enumB=B1;
enumA=_______
enumB=_______
4、
VCHAR *pucCharArray[10][10];
typedef union unRec
{
ULONG ulIndex;
USHORT usLevel[6];
UCHAR ucDos;
}REC_S;
REC_S stMax, *pstMax;
四字節(jié)對齊時 sizeof(pucCharArray)=______
sizeof(stMax)=______
sizeof(*stMax)=______
5、
typedef union unHead
{
UCHAR aucSrc[6];
struct tagContent
{
UCHAR ucFlag[3];
ULONG ulNext;
}Content;
}HEAD_S;
32位CPU,VC編譯環(huán)境下:
強制一字節(jié)對齊情況下,請指出sizeof(HEAD_S)
強制二字節(jié)對齊情況下,請指出sizeof(HEAD_S)
強制四字節(jié)對齊情況下,請指出sizeof(HEAD_S)
6、
四字節(jié)對齊的情況下:
typedef struct tagRec
{
long lA1;
char cA2;
char cA3;
long lA4;
long lA5;
}REC_S;
void main()
{
REC_S stMax;
printf("\r\n sizeof(stMax)=%d", sizeof(stMax));
return;
}
輸出結(jié)果為: sizeof(stMax)=______
7、
typedef struct tagtest
{
unsigned char ucFlag;
unsigned long ulLen;
}TEST_S;
TEST_S test[10];
四字節(jié)對其時: sizeof(TEST_S)=_____ sizeof(test)=______
8、
#pragma pack(4)
int main(int argc, char* argv[])
{
struct tagtest1
{
short a;
char d;
long b;
long c;
}
struct tagtest2
{
long b;
short c;
char d;
long a;
}
struct tagtest3
{
short c;
long b;
char d;
long a;
}
struct tagtest1 stT1;
struct tagtest2 stT2;
struct tagtest3 stT3;
printf("%d %d %d", sizeof(stT1), sizeof(stT2), sizeof(stT3));
return 0;
}
#pragma pack()
輸出是______
9、
typedef struct Head
{
VCHAR aucSrc[6];
VLONG ulType;
}HEAD_S;
在強制一字節(jié)對其的情況下,sizeof(HEAD_S)=____
在強制二字節(jié)對其的情況下,sizeof(HEAD_S)=____
10、
union tagAAAA
{
struct
{
char ucFirst;
short usSecond;
char ucThird;
}half;
long lI;
}number;
struct tagBBBB
{
char ucFirst;
short usSecond;
char ucThird;
short usForth;
}half;
struct tagCCCC
{
struct
{
char ucFirst;
short usSecond;
char ucThird;
}half;
long lI;
};
在字節(jié)對其為1的情況下:
sizeof(union tagAAAA)=_____
sizeof(struct tagBBBB)=____
sizeof(struct tagCCCC)=____
字節(jié)對齊為4的情況下:
sizeof(union tagAAAA)=_____
sizeof(struct tagBBBB)=____
sizeof(struct tagCCCC)=____