strncat() function (string concatenate) in C.

 

01  #include <stdio.h>
02 #include <string.h>
03
04 int main()
05
06 {
07 char s1[80];
08 char s2[80];
09 unsigned int len;
10
11 printf("Enter the first string :");
12 gets(s1);
13 printf("Enter the second string :");
14 gets(s2);
15
16 /* compute how many charaters will actually fit */
17 len = 79- strlen(s1);
18 strncat(s1,s2,len);
19 puts(s1);
20
21 return 0;
22 }
 
 OUTPUT :

Enter the first string :Hello

Enter the second string :World

HelloWorld

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.