C++ tutorial-append() function

C++ String Manipulation

C++ append() function

The append() function is used to add a string to the end of another string. The append() function has two forms. The first form appends all characters in a string to another string. The second form appends part of string to another string. This proportion of string is taken out by starting from the start argument and the num_chars arguments specifies the number of characters to be taken out.


append(string, start, num_chars);


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

using namespace std;

void strmanip(){

  string str="C++ programming";
  str.append(" in easy steps");//append entire string " in easy steps" to another string str
  str.append(" in easy steps",3,5);//append part of string " in easy steps" to another string str


int main(){

  return 0;



srftsf comment




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.