raxfeer 发表于 2012-5-4 17:49:34

Some Question Of Sizeof

#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;
        printf("%d\n",sizeof(a));
}
//result:400
//question:the variable "a" stand for all of "group a"?
/*****************************************************************/
#include <stdio.h>
void main()
{
        int a;
        printf("%d\n",sizeof(a));
}
//result:4
//question:the last member isn't a??
/*****************************************************************/
#include <stdio.h>
void main()
{
        int a;
        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;
        printf("%d\n",sizeof(&a));
}
//result:4
//it's easy to understand,"a"is the part of digit group and the size of "a"'s pointer is 4
/*****************************************************************/
//last question:what's the mean of "sizeof (int) *p"??





页: [1]
查看完整版本: Some Question Of Sizeof