用C语言编程:编写一个函数,将两个字符串连接起来

要求用函数catStr(char str1[],char str2[])
忘记说了,不能使用strcat等函数。
一:闹笑备char* catStr(char str1[],char str2[])

{
strcat(str1,str2);
return str1;
}
二:升空
char* catStr(char str1[],char str2[])
{
int i=0;
int lenstr1=0;
lenstr=strlen(str1)
for(i;i<=strlen(str);i++)
{
str1[lenstr++]=str2[1];
}
return str1;液毁
}
给你个雹告linux的旦谨库函数源码:
/* Append SRC on the end of DEST. */
char *
strcat (dest, src)
char *dest;
const char *src;
{
char *s1 = dest;
const char *s2 = src;
reg_char c;
/模肆基* Find the end of the string. */
do
c = *s1++;
while (c != '\0');
/* Make S1 point before the next character, so we can increment
it while memory is read (wins on pipelined cpus). */
s1 -= 2;
do
{
c = *s2++;
*++s1 = c;
}
while (c != '\0');
return dest;
}

选自:《握清坦程序逻辑及C语言》,本视频为字符串的第04小节。主要讲解四个常用的字符串处理函数,包括:求字符串的长度、字符串的赋正亏值、字符串的连接已经字符串大小的比较。具体有案例讲段桐解。


void catStr(char str1[],char str2[])

{
strcat(str1, str2);

}