niusouti.com
参考答案和解析
参考答案C
更多“将两个字符串连接起来组成一个字符串时,选用( )函数。A、strlen()B、strcap()C、strcat()D、strcm ”相关问题
  • 第1题:

    13、strcat函数的作用是把两个字符串连接起来


    正确

  • 第2题:

    可以用函数strcat将两个字符串连接,也可以用+将两个字符串连接。


    B

  • 第3题:

    不使用strcat函数,将两个字符串连接起来


    void fun (char p1[]char p2[]) { int ij; for (i=0;p1 [i] !='\\0'; i++); /*求出的i为p1字符的总长度包括结束标记位*/ for (j=0;p2 [j] !='\\0'; j++) p1 [i++]=p2 [j]; /*将p2字符串连在p1字符串的后面*/ p1[i]='\\0'; /*在字符串最后加上结束标记符*/ } void fun (char p1[],char p2[]) { int i,j; for (i=0;p1 [i] !='\\0'; i++); /*求出的i为p1字符的总长度,包括结束标记位*/ for (j=0;p2 [j] !='\\0'; j++) p1 [i++]=p2 [j]; /*将p2字符串连在p1字符串的后面*/ p1[i]='\\0'; /*在字符串最后加上结束标记符*/ } 解析:本题用两个循环,第1个循环的作用是将i走到第1个字符串的末尾。第2个循环的作用是将第2个字符串的字符连到第1个字符串的末尾。

  • 第4题:

    【简答题】编程实现将两个字符串连接起来。(不用strcat函数实现)


    #include<string.h> main() { char str1[80],str2[80]; gets(str1); gets(str2); if(strcmp(str1,str2)>0) { strcat(str2,str1); puts(str2); } else { strcat(str1,str2); puts(str1); } }

  • 第5题:

    编一程序,将两个字符串连接起来,不要用strcat函数


    #include<string.h> main() { char str1[80],str2[10],i; gets(str1); gets(str2); n=strlen(str1); i=n; j=0; while(str2[j]!='\0') { str1[i]=str2[j]; i++; j++; } str1[i]='\0'; puts(str1); }