push_back

Syntax:

    #include <string>
    void push_back( Char c );

The push_back() function appends c to the end of the string. For example, the following code adds 10 characters to a string:

     string the_string;
     for( int i = 0; i < 10; i++ )
       the_string.push_back( i+'a' );

When displayed, the resulting string would look like this:

    abcdefghij

push_back() runs in constant time.

Related Topics: assign, insert