Advertisement
Nabil-Ahmed

Untitled

Jul 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. //concatenate two string with out using strcat() function //
  2. #include <stdio.h>
  3. int main()
  4. {
  5.     char str1[50], str2[50], i, j;
  6.     printf("Enter first string: ");
  7.     gets(str1);
  8.     printf("Enter second string: ");
  9.     gets(str2);
  10.  
  11.     for(i = 0; str1[i] != '\0'; ++i);
  12.     for(j = 0; str2[j] != '\0'; ++j, ++i)
  13.     {
  14.         str1[i] =  str2[j];
  15.     }
  16.     str1[i] = '\0';
  17.     printf(" %s", str1);
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement