-
题目描述:
-
不用strcat 函数,自己编写一个字符串链接函数MyStrcat(char dstStr[],charsrcStr[])
-
输入:
-
两个字符串,字符串由小写字母组成。
-
输出:
-
链接后的字符串
-
样例输入:
-
hello world good morning
-
样例输出:
-
helloworld goodmorning
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char* MyStrcat(char dstStr[],char srcStr[]) {
int i,j;
for(i=strlen(dstStr),j=0; j<strlen(srcStr); i++,j++) {
dstStr[i]=srcStr[j];
}
dstStr[i]='\0';
return dstStr;
}
int main() {
char a[1024],b[1024];
while(cin>>a) {
cin>>b;
cout<<MyStrcat(a,b)<<endl;
}
return 0;
}