Advertisement
rafikamal

String Concatination

Jan 23rd, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void stringConcat(char str1[], char str2[]);
  4.  
  5. int main()
  6. {
  7.     char s1[] = "BUET";
  8.     char s2[100] = "Programming";
  9.  
  10.     stringConcat(s1, s2);
  11.  
  12.     printf(s2);
  13.  
  14.     return 0;
  15. }
  16.  
  17. void stringConcat(char str1[], char str2[])
  18. {
  19.     int i, j;
  20.  
  21.     for(i = 0; str2[i] != '\0'; i++)
  22.         ;
  23.     for(j = 0; str1[j] != '\0'; i++, j++)
  24.         str2[i] = str1[j];
  25.     str2[i] = '\0';
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement