sizeof用法体会

来源:互联网 发布:emc unity 重复数据 编辑:程序博客网 时间:2024/06/17 23:09

定义一个结构体如:

typedef  struct  Image

{

    int iWidth;

    int iHeight;

}Image;

 

Image *pImage;

 sizeof(*pImage)返回长度为8:因为*pImage代表的意思是pImage所指向Image变量,故长度为8。

sizeof(pImage)返回4:此时pImage是一个指针变量,所有指针变量的长度都是4.

原创粉丝点击