strncat(): Concatenation of part of string
#include <stdio.h>
#include <string.h>
int main(void){
char var1[20]="plus2net";
char var2[]="welcome to ";
strncat(var2,var1,5);
printf(var2);
return 0;
}
The output of above code is here
welcome to plus2
We can use string function strncat()
to concatenate part of strings.
The part of second string is added at the end of the first string.
strncat(destination_string, source_string,n);
- Source string is not affected
- Part of the Source string is added at the end of the destination string.
This article is written by plus2net.com team.
plus2net.com