C++ | Using strings and concatenation of strings.


This is a tutorial for using strings in c++. The program is given below that prints your name. The program is extendable. Go enjoy the program. Lets begin……

Program to use strings and do concatenation of strings

void main()
//clear the screen.
//declare variable type char
char s[100],*str;
char ss[100],*sstr;
char *ssstr;
//Input the string
cout<<“Enter your name.”<<endl;
cout<<“Enter your surname.”<<endl;
int l = strlen(s);
int ll = strlen(ss);
str = new char[l+1];
sstr = new char[ll+1];
ssstr = new char[l+ll+3];
strcat(ssstr,” “);
//show the output
cout<<“Hello, “<<ssstr;
//get character


Enter your name.
“Enter your surname.
Hello, Abc Xyz

How it works

  1. You enter your name and surname
  2. Program does concatenation of your name and surname.
  3. Program says hello to you.

Extending it

The program can be extended by using the concept in any program.

  • Remember this is a basic part of c++ which can be used in any program….


  1. Include ‘iostream.h’, ‘conio.h’, ‘stdio.h’ and ‘string.h’ files.
  2. Add void main.
  3. Start program by first clearing the screen.
  4. Delcare variables.
  5. Add the gets() funtion for getting string.
  6. Concat string.
  7. Print the string.

At the end

You learnt creating the C++ program for using strings and concatenation of strings in c++. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s