是否指针的大小用C有什么不同? [英] Does the size of pointers vary in C?

查看:104
本文介绍了是否指针的大小用C有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能显示的文件:结果
  <一href=\"http://stackoverflow.com/questions/1473935/can-the-size-of-pointers-vary-depending-on-whats-pointed-to\">Can指针的长度取决于什么大局;指出结果?
  <一href=\"http://stackoverflow.com/questions/916051/are-there-are-any-platforms-where-pointers-to-different-types-have-different-size\">Are有什么平台,其中三分球不同类型有不同的大小?

有没有可能是一个指针在C浮点大小从不同的指针为int?已经尝试过了,我得到了相同的结果对于所有类型的指针。

Is it possible that the size of a pointer to a float in c differs from a pointer to int? Having tried it out, I get the same result for all kinds of pointers.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("sizeof(int*): %i\n", sizeof(int*));
    printf("sizeof(float*): %i\n", sizeof(float*));
    printf("sizeof(void*): %i\n", sizeof(void*));
    return 0;
}

在这里哪一个输出(OSX 10.6 64位)

Which outputs here (OSX 10.6 64bit)

sizeof(int*): 8
sizeof(float*): 8
sizeof(void*): 8

我可以假设,不同类型的指针都具有相同的尺寸(当然上一弓)?

Can I assume that pointers of different types have the same size (on one arch of course)?

推荐答案

指针并不总是在同一拱相同的尺寸。

Pointers are not always the same size on the same arch.

您可以阅读更多的概念近,远和巨大的指针,只是作为一种情况的例子,其中指针大小不同...

You can read more on the concept of "near", "far" and "huge" pointers, just as an example of a case where pointer sizes differ...

<一个href=\"http://en.wikipedia.org/wiki/Intel_Memory_Model#Pointer_sizes\">http://en.wikipedia.org/wiki/Intel_Memory_Model#Pointer_sizes

这篇关于是否指针的大小用C有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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