#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;
bool str_cat(char *a1,char *a2,char *a3,int len)
{
int pos=0;
if(!a3||len<1)
{
return false;
}
if(a1)
{
while(*a1 && pos<(len-1))
{
*(a3+pos)=*a1;
pos++;
a1++;
}
}
if(a2)
{
while(*a2 && pos<(len-1))
{
*(a3+pos)=*a2;
pos++;
a2++;
}
}
*(a3+pos)='\0';
}
int main(void)
{
char *a1="我是";
char *a2="萌小新";
char a3[64];
str_cat(a1,a2,a3,64);
cout<<a3<<endl;
system("pause");
return 0;
}
运行结果: