内存对齐
#include "stdio.h" #include "malloc.h" typedef struct tagstruct { char a; long b; short c; }structm; int main() { structm *pstruct=NULL; pstruct=(structm * )malloc(2*sizeof(structm)); if (NULL==pstruct) { return 1; } pstruct->a=0x11; pstruct->b=0x12345678; pstruct->c=0x3377; pstruct+=1; pstruct->a=0x44; pstruct->b=0x12345678; pstruct->c=0x5588; printf("%d",pstruct->a); printf("%d",pstruct->b); printf("%d",pstruct->c); pstruct--; free(pstruct); return 0; }