A-A+

以下程序 #include<stdio.h> #include<string.h> main

2022-08-06 01:50:37 问答库 阅读 174 次

问题详情

以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xyz"; strcpy(ar+2,strcat(p1,p2)); printf("%sn",str); } 的输出是______。
A.xyzabcABC
B.zabeABC
C.yzabcABC
D.xyabcABC请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:D
解析:strcat(p1,p2)将字符串abcABC防到了*p1所指向的存储单元中:strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

考点:程序