C++:String Functions
Jump to navigation
Jump to search
The methods and properties of the string type include:
Example | Value | Comment |
---|---|---|
s.length() | 14 | The number of characters |
s == "another" | false | Tests for equality |
s.substr(2,5) | "drew" | Characters from position 2, with a length of 5 |
s + " once" | "Andrew was here once" | The strings are concatenated using + |
s.find("was") | 6 | Returns string::npos if the substring is not there. |