strncat c code example

Example 1: c concatenate strings

char str[80];
strcpy(str, "these ");
strcat(str, "strings ");
strcat(str, "are ");
strcat(str, "concatenated.");

Example 2: strncat in c

Input:  src = "world"
        dest = "Hello "
Output: "Hello world"

Input:  src = "efghijkl"
        dest = "abcd"
Output: "abcdefghi"

Example 3: strncat c

#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("Final destination string : |%s|", dest);
   
   return(0);
}
output:
Final destination string : |This is destinationThis is source|