本文主要是介绍浙江大学PTA C语言-实验11.1 指针数组、指针与函数 6-3 字符串的连接,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
6-3 字符串的连接 (15point(s))
本题要求实现一个函数,将两个字符串连接起来。
函数接口定义:
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] = {’\0’}, str2[MAXS] = {’\0’};
scanf("%s%s", str1, str2);
p = str_cat(str1, str2);
printf("%s\n%s\n", p, str1);return 0;
}
/* 你的代码将被嵌在这里 */
输入样例:
abc
def
输出样例:
abcdef
abcdef
Author
C课程组
Organization
浙江大学
Code Size Limit
16 KB
Time Limit
400 ms
Memory Limit
64 MB
char *str_cat( char *s, char *t )
{strcpy(s+strlen(s),t);return s;
}
这篇关于浙江大学PTA C语言-实验11.1 指针数组、指针与函数 6-3 字符串的连接的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!