string append() in C++

append(): It appends a C string to the given string. It returns a reference to this string.

Parameter: 

__s – The C string to append.

Syntax:

str.append(__s)

For Example:

str = "abc"

str.append("def") => It appennds "def" to the given string.

str = "abcdef"

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string str = "abc";
    str.append("def"); 
    
    cout << str << "\n";

    return 0;
}


No comments:

Post a Comment