关于指针?和存放顺序问题,求指导
#include<stdio.h>#include<stdlib.h>
void *MEN_ADDR;
void men_test(void)
{
unsigned int *pint=NULL;
unsigned short *pshort=NULL;
unsigned char *pchar=NULL;
MEN_ADDR=(void*) malloc(sizeof(int));
pint=(unsigned int*)MEN_ADDR;
pshort=(unsigned short*)MEN_ADDR;
pchar=(unsigned char*)MEN_ADDR;
*pint=0x12345678;
printf("0x%x,0x%x\n",*pshort,*pchar);
pshort++;
*pshort=0x5555;
printf("0x%x,0x%x\n",*pint,*pchar);
}
void main()
{
men_test();
}
为何输出是0x5678,0x78
0x55555678,0x78
而不是0x1234,0x12
0x15555678,0x15
呢?求指导谢谢