xstrcat.c

来自「C语言库函数的源代码,是C语言学习参考的好文档。」· C语言 代码 · 共 44 行

C
44
字号
/* +++Date last modified: 05-Jul-1997 */

/*
**  XSTRCAT.C - String concatenation function
**
**  Notes: 1st argument must be a buffer large enough to contain the
**         concatenated strings.
**
**         2nd thru nth arguments are the string to concatenate.
**
**         (n+1)th argument must be NULL to terminate the list.
*/

#include <stdarg.h>
#include "snip_str.h"

#if defined(__cplusplus) && __cplusplus
 extern "C" {
#endif

char *xstrcat(char *des, char *src, ...)
{
        char *destination = des;
        va_list v;

        va_start(v, src);

        while (src != 0)
        {
                while (*src != 0)
                        *des++ = *src++;
                src = va_arg(v, char *);
        }
        *des = 0;

        va_end(v);

        return destination;
}

#if defined(__cplusplus) && __cplusplus
 }
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?