Member
Functions |
Prototype |
Description |
constructor |
string();
string(const char* str);
string(const str& str); |
Creates
a string object |
size
length |
size()
length() |
Returns
the length of the string |
clear |
clear() |
Clears
the string |
c_str |
c_str() |
Returns
null-terminated char array contents of the string |
find |
size_t
find (const string& str, size_t pos = 0) const;
size_t find (const char* s, size_t pos = 0)
const;
size_t find (char c, size_t pos = 0) const; |
Locates
text in a string. Returns npos if not found |
substr |
string
substr (size_t pos = 0, size_t len = npos) const; |
Returns
a substring of the string object |
Member Operators |
=
assignment |
operator=
(const string& str);
string& operator= (const char* s);
string& operator= (char c); |
Assigns
a value to a string |
[
] index |
char& operator[] (size_t pos);
const char& operator[] (size_t pos) const; |
Returns
the char at a location in the string |
+=
plus equal |
string&
operator+= (const string& str);
string& operator+= (const char* s);
string& operator+= (char c); |
Concatenates
text to a string |
Non-member Operators |
+
plus |
string
operator+ (const string& lhs, const string& rhs);
string operator+ (const string& lhs, const
char* rhs);
string operator+ (const char* lhs, const
string& rhs);
string operator+ (const string& lhs,
char
rhs);
string operator+
(char
lhs, const string& rhs); |
Concatenates
a string and text. Returns a new string. |
Non-member functions |
|
|
getline |
istream&
getline (istream& in, string& str, char delim);
istream& getline (istream& in, string& str); |
Reads
from an input stream into a string |
Member Constants |
|
|
npos |
|
Indicates not found |