#include <string.h>
char *strncat( char *str1, const char *str2, size_t count );
将字符串 str2 中至多 count 个字符连接到字符串 str1 中,追加空值结束符,返回处理完成的字符串。
#include <stdio.h> #include <string.h> int main () { char src[50], dest[50]; strcpy(src, "This is source"); strcpy(dest, "This is destination"); strncat(dest, src, 15); printf("dest=|%s|", dest); return(0); }
输出结果:
dest=|This is destinationThis is source|