#include <stdio.h>
#include <stdlib.h>
void calc(void *ptr)
{
printf("1--%d\n", sizeof(ptr));
printf("1++%d\n", sizeof(*ptr));
}
void main()
{
int i = 0;
unsigned char *pbyBuf;
void *pqueue[10];
pbyBuf = (unsigned char)malloc(200*10);
for (i=0; i++; i<10)
{
pqueue[i] = pbyBuf + i*200;
}
calc(pqueue);
printf("2--%d\n", sizeof(pqueue));
printf("2++%d\n", sizeof(*pqueue));
printf("2**%d\n", sizeof(**pqueue));
printf("2++--%d\n", sizeof(void));
printf("2--**%d\n", sizeof(void*));
return;
}
结果:
1--8
1++1
2--80
2++8
2**1
2++--1
2--**8
应该使用sizeof(void*)来获取指针大小