曲径通幽论坛

标题: strcat() | 字符串连接 [打印本页]

作者: beyes    时间: 2009-10-15 10:39
标题: strcat() | 字符串连接
函数原型
#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]$              /*换行了*/





欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2