当我执行以下代码时:
int main()
{
char **temp;
printf("Size of **temp %d", sizeof(**temp));
printf("Size of *temp %d", sizeof(*temp));
printf("Size of temp %d", sizeof(temp));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
Size of **temp 1
Size of *temp 8
Size of temp 8
Run Code Online (Sandbox Code Playgroud)
我不明白的是char指针的大小是8多少?机器独立吗?
在最初的问题中你没有打电话sizeof.
duskwuff为你修好了.
产出的结果是:
Size of **temp 1
Size of *temp 8
Size of temp 8
Run Code Online (Sandbox Code Playgroud)
原因:
在64位架构上,指针是8字节(无论它们指向什么)
**temp is of type char ==> 1 byte
*temp is of type pointer-to-char ==> 8 bytes
temp is of type pointer-to-pointer-to-char ==> 8 bytes
Run Code Online (Sandbox Code Playgroud)