There are String-oriented replacements for some of the functions described in section S manual pages.
int strcmp(const String&,const String&);
on whether String
s is lexicographically less than, equal to, or greater
t. It is an overloaded function so that you can
strcmp on character pointers as well.
int String::strchr(char) const;
The operators strchr, strrchr,
strcspn are related to the corresponding operations
from string(S), but they return integer offsets
instead of character pointers.
Hence they must be member functions and not overloaded ordinary functions.
s.strrchr(c)) returns the index of the first (last)
occurrence of the character
c in the String
(Remember the offset of the first character of a String is 0.) If
c does not occur in the String,
- 1 is returned.
returns the index of the first occurrence in String
of any character from String
-1 if no character from
s.strcspn(t)) returns the length of the initial
segment of String
s that consists entirely of characters from (not
There are String versions of some of the functions in sections S and C++ of the
manual pages (
that have const character pointer arguments.
which expect a
will work with Strings as arguments because conversion to
char* will happen automatically.
But these functions have been
overloaded because they are much more efficient
when implemented directly for Strings.
The current manual descriptions apply except that
const char* is replaced by
Standard functions that return
char* can be used
to return a
String since conversion of the result from
will happen automatically as well.