sizeof(xxx)的结果其实就是XXX所指类型的大小,

在32位系统中

//cout<<sizeof(unsigned short)<<","//2
// <<sizeof(short)<<","//2
// <<sizeof(int)<<","//4
// <<sizeof(char)<<","//1
// <<sizeof(unsigned char)<<","//1
// <<sizeof(float)<<","//4
// <<sizeof(double)<<","//8
// <<sizeof(long)<<","//4
// <<sizeof(DWORD)<<","//4
// <<sizeof(long long)<<","//8
// <<endl;
//cout<<sizeof(unsigned short*)<<","//4
// <<sizeof(short*)<<","//4
// <<sizeof(int*)<<","//4
// <<sizeof(char*)<<","//4
// <<sizeof(unsigned char*)<<","//4
// <<sizeof(float*)<<","//4
// <<sizeof(double*)<<","//4
// <<sizeof(long*)<<","//4
// <<sizeof(DWORD*)<<","//4
// <<sizeof(long long*)<<","//4
// <<endl;

 

int (*ptr)[10];

cout<<sizeof(ptr)<<endl;//4,这个时候prt指向的是一个数组类型的指针(int*[10]),ptr的类型是int**[10]
cout<<sizeof(*ptr)<<endl;//40 *ptr这个时候指向的是int[10]类型,*ptr的类型是int*[10]

posted on 2013-01-08 21:18  陈孝勇  阅读(3127)  评论(0编辑  收藏  举报