输入两个字符串,编写函数实现两个字符串的连接。
函数接口定义:
在这里描述函数接口。例如:
int strCat(SString *s,SString *t);
s
和 t
均是字符串。 把串 t
连接到串 s
的末尾,成功,返回1;失败,返回0。
裁判测试程序样例:
#include <stdio.h>
#define MAXLEN 40
typedef struct { /*串结构定义*/
char ch[MAXLEN];
int len;
}SString;
int strLength(SString *s); //细节不表
int strCat(SString *s,SString *t);
int main()
{
SString s,t;
gets(s.ch);
s.len=strLength(&s);
gets(t.ch);
t.len=strLength(&t);
if(strCat(&s,&t))
{
puts(s.ch);
}
else
{
printf("not enough space.");
}
return 0;
}
/* 请在这里填写答案 */
输入样例:
hello
world!
输出样例:
hello world!
答案: