- 论坛徽章:
- 0
|
程序如下:
void main(void)
{
typedef struct{
char b;
double c;
} Test;
int iInt;
char cChar;
float fFloat;
double dDouble;
int iLen,cLen,fLen,dLen,pLen,struLen,*p;
Test abctest;
iLen= sizeof iInt;
cLen= sizeof cChar;
fLen= sizeof fFloat;
dLen= sizeof dDouble;
pLen= sizeof p;
struLen=sizeof(Test);
printf("sizeof int[%d]\n",iLen);
printf("sizeof char[%d]\n",cLen);
printf("sizeof float[%d]\n",fLen);
printf("sizeof double[%d]\n",dLen);
printf("sizeof struct[%d]\n",struLen);
}
输出:
sizeof int[4]
sizeof char[1]
sizeof float[4]
sizeof double[8]
sizeof struct[12]
可是,如果将结构Test中的char和duble换个位置的话,则输出的
sizeof struct为16
哪为高人帮忙指点小弟一把,谢谢了! |
|