是利用指针来完成
strcat
原型:extern char *strcat(char *dest,char *src);
用法:#include <string.h>
功能:把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'。
返回指向dest的指针。
strcat 源码实现
Char* strcat ( char * dst , const char * src )
用法:#include <string.h>
功能:Concatenates src onto the end of dest. Assumes enough space in dest.
返回结果:The address of "dst"
源码实现:
Char* strcat ( char * dst , const char * src )
{
char * cp = dst;
while( *cp !=’\0’)
cp++;
while( (*cp++ = *src++)!=’\0’ ) ;
return( dst );
}
原型:extern char *strcat(char *dest,char *src);
用法:#include <string.h>
功能:把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'。
返回指向dest的指针。
strcat 源码实现
Char* strcat ( char * dst , const char * src )
用法:#include <string.h>
功能:Concatenates src onto the end of dest. Assumes enough space in dest.
返回结果:The address of "dst"
源码实现:
Char* strcat ( char * dst , const char * src )
{
char * cp = dst;
while( *cp !=’\0’)
cp++;
while( (*cp++ = *src++)!=’\0’ ) ;
return( dst );
}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2008-12-10
strcat函数,是C的标准函数。
char *strcat(
char *strDestination,
const char *strSource
);
The strcat function appends strSource to strDestination and terminates the resulting string with a null character.
strcat函数将strSource添加到strDesination后面,并用一个0结束符中止字符串。
比如说:
char str1[100] = "Thank ";
char str2[] = "you.";
strcat(str1, str2);
执行这些执行这些代码之后,str1的内容就变成了Thank you.
注意str1的容量必须足够大,即能装的下拼接之后的字符串。否则程序会崩溃的。本回答被网友采纳
char *strcat(
char *strDestination,
const char *strSource
);
The strcat function appends strSource to strDestination and terminates the resulting string with a null character.
strcat函数将strSource添加到strDesination后面,并用一个0结束符中止字符串。
比如说:
char str1[100] = "Thank ";
char str2[] = "you.";
strcat(str1, str2);
执行这些执行这些代码之后,str1的内容就变成了Thank you.
注意str1的容量必须足够大,即能装的下拼接之后的字符串。否则程序会崩溃的。本回答被网友采纳
第2个回答 2008-12-10
strcat(str1,str2)
str2 is appent to str1
if you use 2 object such as ,array1[10],array2[10],you can use strcat like strcat(array1,array2).
notice:You've to make sure that array is long enough.
str2 is appent to str1
if you use 2 object such as ,array1[10],array2[10],you can use strcat like strcat(array1,array2).
notice:You've to make sure that array is long enough.