find(), rfind(), compare(), and null terminated string functions in C++

find and rfind() function: These functions are used to search a string.

Syntax of find():

size_type find(const string &a, size_type b=0) const;

Syntax of rfind():

size_type rfind(const string &a, size_type b=n) const;

compare() function: It is used to compare two strings.


int compare(size_type b, size_type c, const string &a) const;

c_str function: It is used to get a null terminated string.


const char *c_str( ) const;

Leave a Reply