69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main(void)
{
char a='A',b='B';
char c='0123';
printf("%d %d\n",sizeof(a),sizeof(c));
printf("%p %p %p %p\n",&a,&b,&c,&c+1);
printf("%c\t%c\t%c\t%c\n",*(&c+3),*(&c+2),*(&c+1),*(&c)); //关键解释这一句
//C就是等于3啊,*(&c+3),*(&c+2),*(&c+1),这段你可以看作是数组一样//
//其实C只有一个地址存在着有效值,你再向后移动n*sizeof(char)是没有用的,这个根本就不存在,所以是任意的东西、
return 0;
}
#include <stdio.h>
int main()
{
int a = '0123';
char *p = (char*)&a;
printf( "%c,%c,%c,%c\n", *p, p[1], *(p+2), p[3] );
return 0;
}