6-7 '字符串03-字符串联接(复合加赋值)(10 分)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41611106/article/details/82595415

C语言标准函数库中包括 strcat 函数,用于字符串联接(复合加赋值)。作为练习,我们自己编写一个功能与之相同的函数。
函数原型

// 字符串联接(复合加赋值)
char* StrCat(char *dst, const char *src);

说明:src 为源串的起始地址,dst 为目的串起始地址。函数将 src 串添加到 dst 串末尾,函数值为 dst。
裁判程序

#include <stdio.h>
// 字符串联接(复合加赋值)
char* StrCat(char *dst, const char *src);

int main()
{
    char a[1024], b[1024];
    gets(a);
    gets(b);
    StrCat(a, b);
    puts(a);
    return 0;
}

/* 你提交的代码将被嵌在这里 */

输入样例

abc
de

输出样例

abcde

char* StrCat(char *dst, const char *src)
{
    char *asd;
    asd=strcat(dst,src);
    return asd;
}

猜你喜欢

转载自blog.csdn.net/qq_41611106/article/details/82595415