|
#include <stdio.h>
void main()
{
int *p=NULL;
printf("%d\n",sizeof(p));
}
//result:4
//question:it means the pointer occupy 4 byte of memory?
/*****************************************************************/
#include <stdio.h>
void main()
{
int *p=NULL;
printf("%d\n",sizeof(*p));
}
//result:4
//it's easy to understand,the variable take up 4 bytes,right?
/*****************************************************************/
#include <stdio.h>
void main()
{
int a[100];
printf("%d\n",sizeof(a));
}
//result:400
//question:the variable "a" stand for all of "group a"?
/*****************************************************************/
#include <stdio.h>
void main()
{
int a[100];
printf("%d\n",sizeof(a[100]));
}
//result:4
//question:the last member isn't a[99]??
/*****************************************************************/
#include <stdio.h>
void main()
{
int a[100];
printf("%d\n",sizeof(&a));
}
//result:400
//question:it means count all members' pointers?before this test,we already known the size of pointer is 4.
/*****************************************************************/
#include <stdio.h>
void main()
{
int a[100];
printf("%d\n",sizeof(&a[0]));
}
//result:4
//it's easy to understand,"a[0]"is the part of digit group and the size of "a[0]"'s pointer is 4
/*****************************************************************/
//last question:what's the mean of "sizeof (int) *p"??
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|