#include <iostream>
using namespace std;
char*astrcat(char str1[],const char str2[]);
int main()
{
char s1[50]="Hello world.";
char s2[50]="Good morning.";
astrcat(s1,s2);
cout<<"连接后:"<<s1<<endl;
return 0;
}
char*astrcat(char str1[],const char str2[])
{
int i,j;
for(i=0;*(str1+i)!='\0';i++);
for(j=0;*(str2+j)!='\0';i++,j++)
{
*(str1+i)=*(str2+j);
}
*(str1+i)='\0';
return str1;
}
字符串连接
最新推荐文章于 2021-12-13 00:19:33 发布