Skip to content
C++

<string> API Reference

C++ std::string — a contiguous, growable sequence of chars with a rich member-function interface.

By EZ4Code Team

std::string

The C++ standard library string class, a specialization of std::basic_string for char.

std::string::size() const noexcept -> size_t

Returns the number of characters in the string, not including the null terminator.

Returns: size_t

std::string::append(const string& s) -> string&

Appends the given string to the end of this string.

Returns: string&

std::string::substr(size_t pos = 0, size_t len = npos) const -> string

Returns a substring starting at pos with length len (or to the end if npos).

Returns: string

std::string::find(const string& s, size_t pos = 0) const -> size_t

Searches for the first occurrence of s starting at pos. Returns npos if not found.

Returns: size_t

std::string::c_str() const noexcept -> const char*

Returns a pointer to a null-terminated C string representation of the string's data.

Returns: const char*

std::string::replace(size_t pos, size_t len, const string& s) -> string&

Replaces the portion of the string starting at pos with length len by the string s.

Returns: string&

More C++ API References