曲径通幽论坛

 找回密码
 立即注册
搜索
查看: 4761|回复: 0
打印 上一主题 下一主题

[字符串] strcat() | 字符串连接

[复制链接]

4918

主题

5880

帖子

3万

积分

GROAD

曲径通幽,安觅芳踪。

Rank: 6Rank: 6

积分
34395
跳转到指定楼层
楼主
发表于 2009-10-15 10:39:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
函数原型
#include <string.h>
char *strcat(char *dest, const char *src);

说明
把 src 指向的源字符串连接到 dest 指向的字符串中,形成新的字符串存在 dest 中。在这里,连接时, src 会覆盖掉 dest 字符串后面的 '\0' 。

测试代码
#include <stdio.h>
#include <string.h>


int main ()
{
        char buf [64] = "hello world";
        printf ("%s", buf);

        strcat (buf, "\n");
        printf ("%s", buf);

        return (0);
}
运行与输出
[beyes@localhost string]$ ./strcat.exe
hello worldhello world
[beyes@localhost string]$              /*换行了*/
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )

GMT+8, 2025-5-4 01:06 , Processed in 0.078059 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表