> 其他 >
解释一下这个程序是啥意思
#include "stdio.h"
main()
{
char *p="abcdefgh",*r;
long *q;
q=(long*)p;
q++;
r=(char*)q;
printf("%s\n",r);
}
人气:418 ℃ 时间:2020-06-07 15:51:17
解答
楼主要明白各变量所占空间大小
#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);
}
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版