/*
* strcat 连接字符串
*/
#include <cstdio>
char * strcat ( char * destination, const char * source ) {
char *p = (char *)source;
while (*destination++ != '\0')
;
--destination;
while (*destination++=*p++)
;
return p-1;
}
int main ()
{
char str[80] = {0};
strcat (str,"these ");
strcat (str,"strings ");
strcat (str,"are ");
strcat (str,"concatenated.");
puts (str);
return 0;
}
C 标准库 strcat 函数的实现
最新推荐文章于 2023-10-13 17:44:34 发布
本文介绍了一个使用C语言实现的字符串连接函数strcat的示例代码。该函数通过遍历源字符串并将每个字符复制到目标字符串的末尾来完成字符串的拼接。文中还展示了一个主函数,用于演示如何连续拼接多个字符串。
1714

被折叠的 条评论
为什么被折叠?



