有以下程序 #include void fun(char *t,char *s) { while(*t!=0) t++; while((*t++=*s++)!=0); } main() { char ss[10]="acc",aa[10

admin2010-12-10  40

问题 有以下程序
#include  
void fun(char *t,char *s)
{ while(*t!=0)  t++;
while((*t++=*s++)!=0);
}
main()
{ char ss[10]="acc",aa[10]="bbxxyy";
fun(ss,aa);  printf("%s,%s\n",ss,aa);
}
程序的运行结果是

选项 A、accxyy,bbxxyy
B、acc,bbxxyy
C、accxxyy,bbxxyy       
D、accbbxxyy,bbxxyy

答案D

解析 本题中fun函数实现了字符串函数strcat的功能,将字符串aa连接到字符串ss的末尾。调用fun函数时,形参t和s分别指向了字符串ss和aa,然后通过一个while循环使t指向字符串ss的结束符的位置,第二个while循环将字符串aa中的字符(包括结束符’\0’)逐个复制到字符串ss的末尾处。
转载请注明原文地址:https://kaotiyun.com/show/l1Pp777K
0

最新回复(0)