题目描述
写一函数,将两个字符串连接输入
两行字符串输出
链接后的字符串样例输入
123
abc
样例输出
123abc
1 #include <stdio.h>
2 #include <string.h>
3
4 void str_cat(char s1[], char s2[])
5 {
6 int l1 = strlen(s1);
7 int l2 = strlen(s2);
8 int i;
9
10 for(i = l1; i < l1 + l2; i++)
11 {
12 s1[i] = s2[i-l1];
13 }
14
15 s1[i] = '\0';
16 }
17
18 int main(int argc, char const *argv[])
19 {
20 char s1[81], s2[81];
21
22 scanf("%s", s1);
23 scanf("%s", s2);
24
25 str_cat(s1, s2);
26
27 printf("%s\n", s1);
28 return 0;
29 }