Advertisement
galib71

STRING_PRB_1

Jan 31st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. /* char s1[50];
  9. char s2[50];
  10. char a[2]=" ";
  11. cin.getline(s1,50);
  12. cout<<endl;
  13. cin.getline(s2,50);
  14. cout<<endl;
  15. strcat(s1,a);
  16. strcat(s1,s2);
  17. cout<<s1;*/
  18. int i=0,j=0,k=0;
  19. char s1[50],s2[50],s3[6]=" ";
  20. cout<<"Enter first string : ";
  21. cin.getline(s1,50);
  22. cout<<"Enter second string : ";
  23. cin.getline(s2,50);
  24. for(;s1[i]!='\0';i++){}
  25. while(s3[k]!='\0')
  26. {
  27. s1[i++]=s3[k++];
  28. }
  29. while(s2[j]!='\0')
  30. {
  31. s1[i++]=s2[j++];
  32. }
  33. s1[i]='\0';
  34. cout<<endl;
  35. cout<<"Now : "<<s1;
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement