asadlive84

Untitled

Mar 1st, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     char a[100],b[100];
  5.     char string[100];
  6.     int c;
  7.     printf("Type your first word: ");
  8.     gets(a);
  9.     printf("Type your 2nd name: ");
  10.     gets(b);
  11.     c=str_concat(a,b);
  12.     int ntp=str_len(a,b);
  13.     printf("\n");
  14.     printf("String: %s and Len is %d\n",c,ntp);
  15.  
  16.  
  17.     return 0;
  18. }
  19.  
  20. int str_concat(char a[100],char b[100])
  21. {
  22.     int i,j,m=0;
  23.  
  24.     for(i=0;a[i]!='\0';i++)
  25.     {
  26.         m++;
  27.     }
  28.  
  29.     for(i=m,j=0;b[j]!='\0';i++,j++)
  30.     {
  31.         a[i]=b[j];
  32.     }
  33.  
  34.     a[i]='\0';
  35.  
  36.     return a;
  37. }
  38.  
  39. int str_len(char a[100],char b[100])
  40. {
  41.     int i,j,m=0;
  42.  
  43.     for(i=0;a[i]!='\0';i++)
  44.     {
  45.         m++;
  46.     }
  47.  
  48.     for(i=m,j=0;b[j]!='\0';i++,j++)
  49.     {
  50.         a[i]=b[j];
  51.     }
  52.  
  53.     a[i]='\0';
  54.  
  55.     m=0;
  56.  
  57.     for(i=0;a[i]!='\0';i++)
  58.     {
  59.         m++;
  60.     }
  61.  
  62.     return m;
  63. }
Add Comment
Please, Sign In to add comment