W
westbest98
Hi,everyone!
i worder how the computer allocate the space for variable.
the program like this:
printf("sizeof(int)=%d,sizeof(char)=%d",sizeof(int),sizeof(char));
int a=10,b=20;
char c[]="123",d[10]="123";
printf("\na=%x,b=%x,c=%x,d=%x",&a,&b,c,d);
then i get the result:
sizeof(int)=4,sizeof(char)=1
a=22ff6c,b=22ff68,c=22ff64,d=22ff50
i know that (a-b),there is a size of space for int,but why (c-d) there
is 20,not 10,like i do d[10]!
Thanks for your solutions!
i worder how the computer allocate the space for variable.
the program like this:
printf("sizeof(int)=%d,sizeof(char)=%d",sizeof(int),sizeof(char));
int a=10,b=20;
char c[]="123",d[10]="123";
printf("\na=%x,b=%x,c=%x,d=%x",&a,&b,c,d);
then i get the result:
sizeof(int)=4,sizeof(char)=1
a=22ff6c,b=22ff68,c=22ff64,d=22ff50
i know that (a-b),there is a size of space for int,but why (c-d) there
is 20,not 10,like i do d[10]!
Thanks for your solutions!