问题 单项选择题

以下程序#include<stdio.h>#include<string.h>main() { char*pl="abc",*p2="ABC",str[50]="xyz";strcpy(str+2.strcat(p1,p2));printf("%s\n,str); }的输出是______。

A.xyzabcABC

B.zabcABC

C.yzabcABC

D.xyabcABC

答案

参考答案:D

解析:[评析] strcat(p1,P2)将字符串abcABC放到了*pl所指向的存储单元中;strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

多项选择题 案例分析题
填空题 案例分析题