Posted on 2009-10-28 00:18
小苏 阅读(788)
评论(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.不可预知
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;
四字节对齐时 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编译环境下:
强制一字节对齐情况下,请指出sizeof(HEAD_S)
强制二字节对齐情况下,请指出sizeof(HEAD_S)
强制四字节对齐情况下,请指出sizeof(HEAD_S)
6、
四字节对齐的情况下:
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;
}
输出结果为: sizeof(stMax)=______
7、
typedef struct tagtest
{
unsigned char ucFlag;
unsigned long ulLen;
}TEST_S;
TEST_S test[10];
四字节对其时: 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;
在强制一字节对其的情况下,sizeof(HEAD_S)=____
在强制二字节对其的情况下,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;
};
在字节对其为1的情况下:
sizeof(union tagAAAA)=_____
sizeof(struct tagBBBB)=____
sizeof(struct tagCCCC)=____
字节对齐为4的情况下:
sizeof(union tagAAAA)=_____
sizeof(struct tagBBBB)=____
sizeof(struct tagCCCC)=____