函数原型:extern char *strncat(char *dest,char *src,int n)
参数说明:src为源字符串,dest为目的字符串,n为指定的src中的前n个字符。
所在库名:#include <string.h>
函数功能:把src所指字符串的前n个字符添加到dest结尾处,覆盖dest结尾处的'/0',实现字符串连接。
返回说明:返回指针,连接后的字符串。
小例子:
#include <stdio.h>
#include <string.h>
int main()
{
char str[100] = "SKY2098, YOU";
char *str2 = "are the hero!but iuu";
int n = 15;
char *strtemp;
strtemp = strncat(str, str2, 13 );
printf("This string strtemp is: %s\n", strtemp);
return 0;
}
~
输出为:
This string strtemp is: SKY2098, YOUare the hero!