Table of Contents Previous topic Next topic
C++ COMPILER LIBRARY FUNCTIONS->String Class Functions->Member Functions->compare
#include <string>
int compare(const string& str) const
Return the result of comparing the data of an object of class string with the data of str.
int compare(size_t pos1, size_t n1, const string& str) const
Return the result of comparing the data starting at position pos1 of an object of class string with the data of str. The number of characters compared is the smaller of n1 and size() pos1.
int compare(size_t pos1, size_t n1, const string& str, size_t pos2, size_t n2) const
Return the result of comparing the data starting at position pos1 of an object of class string with the data of str starting at str[pos2]. The number of characters compared is the smaller of n1 and size() pos1 and the smaller of n2 and str.size() pos2.
int compare(const char* s) const
Return the result of comparing the data of an object of class string with the array of char of size strlen(s) whose first element is s.
int compare(size_t pos1, size_t n1, const char* s, size_t n2 = npos) const
Return the result of comparing n1 characters of data starting at position pos1 of an object of class string with the array of char whose first element is s.
The number of characters compared in the array is n2 if n2 is not equal to npos otherwise it is strlen(s).