strcat() in C++ by R4R Team

use of strcat() function:
-This function are used to concate two string.

Syntax-
strcat(string1,string2)
-Result is stored in string1.

Example-
string1 is "My"
string2 is "Website"
After concatenation : "MyWebsite"

program:

#include< iostream>
#include< string.h>
int main()
{
char ch1[20],ch2[20];
int i=0,len=0;
//input of string
cout<<"Enter first string"<< endl;
cin>>ch1;
cout<<"Enter second string"<< endl;
cin>>ch2;
strcat(ch1,ch2);
cout<<"Now first string is "<< ch1;
}


output-

Enter first string
Myprogram
Enter second string
_isgood
Now first string is Myprogram_isgood

-In this program, we take an input of the two string and pass in strcat() function.
-strcat() return the required string and store in string1.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!