#include "stdio.h"
typedef unsigned long DWORD;
typedef struct tagICMPHDR
{
unsigned char Type;
unsigned char Code;
unsigned short Checksum;
unsigned short ID;
unsigned short Seq;
char Data;
}ICMPHDR;
typedef struct tagECHORE
{
ICMPHDR icmpHdr;
DWORD dwTime;
char cData[32];
}ECHOREQUEST;
void main()
{
ECHOREQUEST est;
printf("%d\n",sizeof(est));
}
上面的代码输出是什么呢?
答案是 48 ,
sizeof(ICMPHDR)答案是10 ,sizeof(DWORD)=4,sizeof(cData)等于多少?是个数组,我们知道sizeof(char)是1,所以sizeof(cData)为32.
如果你有不同的答案或不能理解就给我留言