以下程序的运行结果是【 】。 #include<iostream> #include<string> using namespace std; void main(){ chara[10]="China",b[]="

admin2013-02-27  22

问题 以下程序的运行结果是【  】。
   #include<iostream>
   #include<string>
   using namespace std;
   void main(){
       chara[10]="China",b[]="Chin",c[]="ese";
       cout<<strlen(strcat(strcpy(a,b),c))<<endl;
   }

选项

答案7

解析 本题主要考查C++中字符串函数的使用。strcpy(s1,s2)将s2的内容赋值到s1中; strcat(s1,s2)连接s1和s2两个字符串;strlen(s)返回字符数组s的长度。因此最后输出的结果是b和c进行连接后的字符串长度,即7。
转载请注明原文地址:https://jikaoti.com/ti/vjL0FFFM
0

最新回复(0)