Samiul_Islam_Abir

005

Jul 25th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     char s1[100], s2[100], i, j;
  5.     printf("Enter string1: ");
  6.     scanf("%s", s1);
  7.     printf("Enter string2: ");
  8.     scanf("%s", s2);
  9.     // calculate the length of string s1
  10.     // and store it in i
  11.     for(i = 0; s1[i] != '\0'; ++i);
  12.     for(j = 0; s2[j] != '\0'; ++j, ++i)
  13.     {
  14.         s1[i] = s2[j];
  15.     }
  16.     s1[i] = '\0';
  17.     printf("After concatenation: %s", s1);
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment