c/c++语言开发共享字符串的连接

6 2 字符串的连接 (10 分) 本题要求实现一个函数,将两个字符串连接起来。 函数接口定义: char str_cat( char s, char t ); 函数str_cat应将字符串t复制到字符串s的末端,并且返回字符串s的首地址。 裁判测试程序样例: include include def …

6-2 字符串的连接 (10 分)
本题要求实现一个函数,将两个字符串连接起来。
函数接口定义:
char str_cat( char s, char *t );
函数str_cat应将字符串t复制到字符串s的末端,并且返回字符串s的首地址。
裁判测试程序样例:

include <stdio.h>

include <string.h>

define maxs 10

char str_cat( char s, char *t );

int main()
{
char *p;
char str1[maxs+maxs] = {‘’}, str2[maxs] = {‘’};

scanf("%s%s", str1, str2); p = str_cat(str1, str2); printf("%sn%sn", p, str1);  return 0;

}

/* 你的代码将被嵌在这里 */
输入样例:
abc
def
输出样例:
abcdef
abcdef

char str_cat( char s, char *t )
{
strcat(s,t);
return s;
}

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/604663.html

(0)
上一篇 2021年5月12日
下一篇 2021年5月12日

精彩推荐