belongs to collection: C++ language Pointer Exercises
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
#include <iostream> #define MAX_SIZE 100 // Maximum size of the string using namespace std; int main() { char str1[MAX_SIZE], str2[MAX_SIZE]; char * s1 = str1; char * s2 = str2; // Inputting 2 strings from user cout<<"Enter 1st string: "; cin>>str1; cout<<"Enter 2nd string: "; cin>>str2; // Moving till the end of str1 while(*(++s1)); // Coping str2 to str1 while(*(s1++) = *(s2++)); cout<<"Concatenated string:"<<str1; return 0; }
Result:
Enter 1st string: Tech
Enter 2nd string: Study
Concatenated string:TechStudy
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
Result:
Enter 1st string: Tech
Enter 2nd string: Study
Concatenated string:TechStudy
need an explanation for this answer? contact us directly to get an explanation for this answer