C++ Program to Concatenate String

« Previous Program Next Program »

Concatenate String in C++

To concatenate or to append one string to another string in C++ Programming, you have to ask to the user to enter the two string and start concatenating one string into other using the strcat() function as shown here in the following program.

C++ Programming Code to Concatenate String

Following C++ program ask the user to enter the two string to concatenate it using the function strcat() of string.h library.

The strcat() function takes the two argument like strcat(str1, str2). Here string of str2 will be appended at the end of the string str1 :

/* C++ Program - Concatenate String */
void main()
	char str1[50], str2[50];
	cout<<"Enter first string : ";
	cout<<"Enter second string : ";
	strcat(str1, str2);
	cout<<"String after concatenation is "<<str1;

When the above C++ program is compile and executed, it will produce the following result:

C++ program concatenate two strings

Same Program in Other Language

You may like the same program in other programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test