followin代码的输出显示4,为什么它显示4作为输出? [英] the output of the followin code displays 4 , why it is displaying 4 as output?

查看:75
本文介绍了followin代码的输出显示4,为什么它显示4作为输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>
#include<conio.h>
int main()
{
     void *p;
     printf("%d",sizeof(p));
     getch();
     return 0;
}



推荐答案

正如我在答复中问到的那样:
p 是一个指针:系统中指针的大小为32位.因此,sizeof(p)返回4-四个字节为32位. p指向什么(void,char,int或nowhere)无关紧要:指针的大小在系统中始终为4个字节.
As I said when you asked this in a reply:
p is a pointer: the size of a pointer in your system is 32 bits. Therefore sizeof(p) returns 4 - four bytes makes 32 bits. It doesn''t matter what p points to (void, char, int, or nowhere): the size of the pointer is always 4 bytes in your system.


指针的大小将通常可能是4个字节,尽管在64位计算机中可能有所不同(8个字节而不是4个字节).
Size of a pointer will usually tend to be 4 bytes, although it may be different in a 64bit machine (8 bytes instead of 4).


这篇关于followin代码的输出显示4,为什么它显示4作为输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆