C++:String Functions

From Progzoo
Jump to navigation Jump to search

The methods and properties of the string type include:

string s="Andrew was here"
s.length()14The number of characters
s == "another"falseTests 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")6Returns string::npos if the substring is not there.