Concatenate two string in C++


Prev Tutorial Next Tutorial

C++ program to concatenate two string

Combined two string or Concatenate two string means add both string with each other, we can perform this operation using library function or without library function. For example if first string is john and second string is porter then after combined these string output will be johnporter.

C++ program to concatenate two strings

#include<iostream.h>
#include<conio.h>
#include<string.h>

void main()
{
char *ch1="john";
char *ch2="porter";
char *ptr;
clrscr();
cout<<"1 st String: "<<ch1;
cout<<"\n 2 nd String: "<<ch2;
strcat(ch1,ch2);
cout<<"\nCombined string is: "<<ch1;
getch();
}

Output

1 st String: john
2 nd String: porter
Combined string is: johnporter

Prev Tutorial Next Tutorial

Yahoo Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com

Download Projects

Adsense Advertisements
Free Classified Site – Bedpage

Yahoo Ads Advertisements