不用strcmp函数实现字符串的连接

#include
using namespace std;
int main()
{
int Count(char b[]);
void Connect(char* des,const char* sou);
char a[50] = “hello”;
char b[] = “,leekaimao”;
Connect(a, b);
cout << "a = " << a << endl;
return 0;
}
int Count(const char* b)
{
int i = 0;
while (b[i] != ‘\0’)
{
i++;
}
return i;
}
void Connect(char* des,const char* sou)
{
int Count(const char *b);
int i, j, len, len1;
len = Count(des);
len1 = Count(sou);
for (i = len, j = 0; i< len + len1; i++, j++)
{
des[i] = sou[j];
}
des[i] = ‘\0’;

}

你可能感兴趣的:(c++)