insert [C++ Reference]
Keywords: string,insert
Date: 2009-10-08T21:47:48-0700

[[insert]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## insert

Syntax:

        #include <string>
        iterator insert( iterator i, char ch );
        string& insert( size_type index, const string& str );
        string& insert( size_type index, const char* str );
        string& insert( size_type index1, const string& str, size_type index2, size_type num );
        string& insert( size_type index, const char* str, size_type num );
        string& insert( size_type index, size_type num, char ch );
        void insert( iterator i, size_type num, char ch );
        void insert( iterator i, input_iterator start, input_iterator end );

The very multi-purpose insert() function either:

- inserts ch before the character denoted by i,
- inserts str into the current string, at location index,
- inserts a substring of str (starting at index2 and num characters long) into the current string, at location index1,
- inserts num copies of ch into the current string, at location index,
- inserts num copies of ch into the current string, before the character denoted by i, before the character specified by i.

Related Topics: erase, replace

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •