C++ String Library - append



Description

It extends the string by appending additional characters at the end of its current value.

Declaration

Following is the declaration for std::string::append.

string& append (const string& str);

C++11

string& append (const string& str);

C++14

string& append (const string& str);

Parameters

  • str − It is a string object.

  • c − It is a character object.

Return Value

It returns *this.

Exceptions

if an exception is thrown, there are no changes in the string.

Example

In below example for std::string::append.

#include <iostream>
#include <string>

int main () {
   std::string str;
   std::string str2="Writing ";
   std::string str3="print 10 and then 5 more";

   str.append(str2);
   str.append(str3,6,3);
   str.append("dots are cool",5);
   str.append("here: ");
   str.append(10u,'.');
   str.append(str3.begin()+8,str3.end());
   str.append<int>(5,0x2E);
   std::cout << str << '\n';
   return 0;
}
Writing 10 dots here: .......... and then 5 more.....
string.htm
Advertisements
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy