以下程序的输出结果是【 14 】#include lt;stdio.hgt; #include lt;stdio.hgt;#include lt;st
程序
已帮助 人
以下程序的输出结果是【 14 】
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{ char *p,*q,*r,
p=q=r=(char*)malioc(sizeof(char)*20);
strcpy(p,"attaboy,welcome!");
printf(”%c%c%c ”,p[ 11 ], q[ 3 ],r[ 4 ]);
free(p);
}
-
参考答案:【答案】cab【知识点】malloc函数与指针变量的使用
【解析】pqr三个指针指向同一个具有20个字符空间的地址。Strcpy函数的作用是将字符串attaboy,welcome!复制到p指针所指向的空间。所以打印时打印的p[11], q[3],r[4]分别为c,a,b。
