mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +00:00
47 lines
734 B
Markdown
47 lines
734 B
Markdown
# 6-3 字符串的连接
|
|
|
|
本题要求实现一个函数,将两个字符串连接起来。
|
|
|
|
### 函数接口定义:
|
|
```c++
|
|
char *str_cat( char *s, char *t );
|
|
```
|
|
函数`str_cat`应将字符串`t`复制到字符串`s`的末端,并且返回字符串`s`的首地址。
|
|
|
|
### 裁判测试程序样例:
|
|
```c++
|
|
#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;
|
|
}
|
|
|
|
/* 你的代码将被嵌在这里 */
|
|
```
|
|
|
|
### 输入样例:
|
|
```in
|
|
abc
|
|
def
|
|
```
|
|
|
|
### 输出样例:
|
|
```out
|
|
abcdef
|
|
abcdef
|
|
|
|
```
|