apl-mhd

stringConCat

Oct 18th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void a(char str2[30],char str1[30],int n){
  6.  
  7.     int size,i;
  8.  
  9.     size = strlen(str2);
  10.     //printf("%d", size);
  11.  
  12.     for( i =0; i<n; i++ ){
  13.  
  14.         str2[size] = str1[i];
  15.  
  16.         size++;
  17.  
  18.     }
  19.     str2[size] = '\0';
  20.  
  21.     printf(" %s \n %s \n", str2, str1);
  22.  
  23.  
  24.  
  25.  
  26. }
  27.  
  28. int main()
  29. {
  30.     char name1[30],name2[30];
  31.     int n;
  32.  
  33.     printf("Enter first string:");
  34.         gets(name1);
  35.     printf("Enter second string:");
  36.         gets(name2);
  37.     printf("Enter copy size:");
  38.         scanf("%d",&n);
  39.  
  40.        // printf("%s %s %d", name1, name2, n);
  41.  
  42.     a(name2, name1, n);
  43.  
  44.     return 0;
  45. }
Add Comment
Please, Sign In to add comment