有时对指针长度总是弄混淆,今天试验了把,总算有个明确的结论了.
指针就是地址,它的长度取决于编译程序的编译器,如果是32位,则指针长度为4字节.若是64位,则是8字节.
#include<stdio.h>
int main()
{
int i = 0;
int *pi = &i;
char c = 0;
char *pc = &c;
printf("sizeof(pi):%d, sizeof(pc):%d", sizeof(pi), sizeof(pc));
printf("sizeof(*pi):%d, sizeof(*pc):%d", sizeof(*pi), sizeof(*pc));
return 0;
}