Function name : strncat
Header file : <string.h>
Function prototype: char *strncat(char *destin,char *str,int n);
Function : Append at the end of a string, that is, add the specified number of characters of one string to the end of another string
Parameters : char *destin appended target string
char *str source string to append
int n Number of characters to append
Return value : Returns the starting address of the destination string
Note : The string destin must have enough space to accommodate the newly added string
Program example : Add the first n characters of the string str after the string destin
#include<stdio.h>#include<string.h>intmain(void){chardestin[30]=Ilike;char*str=www.dotcpp.comverymuch;intn=14;char*newStr=strncat(destin,str, n);printf(%sn,newStr);return0;}
Running results:
Ilikewww.dotcpp.com