C++ Strings
11793 ワード
C++ Strings
Constructors
Syntax:
append
Syntax:
Constructors
Syntax:
string( size_type length, char ch );
string( const char *str );
string( input_iterator start, input_iterator end );
append
Syntax:
basic_string &append( const basic_string &str );
basic_string &append( const char *str );
basic_string &append( const basic_string &str, size_type index, size_type len );
basic_string &append( const char *str, size_type num );
size
Syntax:
The size() function returns the number of characters currently in the string. at Syntax: The at() function returns a reference to the character at location index. If index is not within the string, then at() reports an out of range error by throwing an object of the out_of_range class. For example, this code: displays the character 'C'. begin Syntax: The begin() function returns an iterator to the first element of the current string. erase Syntax: The erase() function either: · removes the character pointed to by pos, returning an iterator to the next character, · removes the characters between start and end, returning an iterator to the character after the last character removed, · or removes num characters from the current string, starting at index, and returns *this. The parameters index and num have default values, which means that erase() can be called with just index to erase all characters after index or with no arguments to erase all characters. For example: will display find The function find() either: insert The very multi-purpose insert() function either:
|