作业帮 > 综合 > 作业

解释一下这个程序是啥意思

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/17 01:13:31
解释一下这个程序是啥意思
#include "stdio.h"
main()
{
char *p="abcdefgh",*r;
long *q;
q=(long*)p;
q++;
r=(char*)q;
printf("%s\n",r);
}
楼主要明白各变量所占空间大小
#include "stdio.h"
main()
{
char *p="abcdefgh",*r;//首先定义了char指针,p在这里占8个
//字节,r未知
long *q;//long型占4个字节
q=(long*)p;//语句q=(long*)p进行了转换赋值,q首地址指向a
q++;//注意变量类型空间,此时q首地址指向e
r=(char*)q;//赋值,r为efgh
printf("%s\n",r);
}