指针的长度就是机器的地址长度,绝大部分情况下跟字长也相符。例如32位机就是32位的指针出长度,换算一下就是4个字节,64位机器上就是8字节,当然也需要CPU,操作系统和编译器的配合才能得到准确的值。就像32位机器上还可以用TC这种16位的编译器,32位的windows可以模拟16位dos环境,32位的x86也可以兼容16位的8086,所以在win32下用TC编译程序就是16位指针。同理在64位的windows下也可以兼容执行32位程序。
以上
struct all
{
struct all *next;
int a,b,c;
}rec;
int main(void)
{
int *a=NULL;
printf("The size of rec is %d,/n"
"and the size of int type is %d/n"
"and the size of all.next is %d/n "
"and the size of a pointer is %d/n",
sizeof(rec),sizeof(int),sizeof(a),sizeof(rec));
getchar();
return 0;
}
输出结果为:
The size of rec is 16,
and the size of int type is 4
and the size of all.next is 4
and the size of a pointer is 16
1万+





