Advertisement
ZinedinZidan

string concatenation

Dec 7th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.   char str1[50]="My name is ";
  7.   char str2[50]="Jamir Uddin Zidan";
  8.   int i=0,len=0,j=0;
  9.   while(str1[i]!='\0')
  10.   {
  11.     i++;
  12.     len++;
  13.   }
  14.   while(str2[j]!='\0')
  15.   {
  16.     str1[len+j]=str2[j];
  17.     j++;
  18.   }
  19.  
  20.  
  21.   printf("str1 = %s\n",str1);
  22.  
  23.  
  24.   return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement