Crossware

Table of Contents        Previous topic       Next topic       

C++ COMPILER LIBRARY FUNCTIONS->String Class Functions->Member Functions->Size and Capacity Operations

#include <string>

size_t size() const

Returns the number of characters in the string.

size_t length() const

Returns the number of characters in the string.

size_t max_size() const

Returns the maximum number of characters permitted in the string.

void resize(size_t n, char c)

Alters the number of characters in the string.

If n < size(), the string data is truncated.

If n > size(), the c is added to the end of the data for fill the additional space.

void resize(size_t n)

Alters the number of characters in the string.

If n < size(), the string data is truncated.

If n > size(), \0 is added to the end of the data for fill the additional space.

size_t capacity() const

Returns the size of the allocated storage in the string.

void reserve(size_t res_arg = 0)

If res_arg < size(), reduces the allocated storage to fit the allocated storage required for the currently contained data.

If res_arg > size(), increases the allocated storage to an amount suitable for res_arg characters.

void clear()

Removes any data and reallocates any storage to the default minimum.

bool empty() const

Returns true if the string contains no data, otherwise it returns false.