C What is the data type of the return value ofstdstringfind

C++

What is the data type of the return value ofstd::string::find()?

What is the value returned by std::string::find()method when a search string is not found?

Solution

What is the data type of the return value ofstd::string::find()?

find() is a method which searches for the first occurence of a string in the string object. And it returns the position of the first character of the substring that matches the substring. If no match is found, it returns npos which is a numerical equivalent to -1. So, the return type of find() is size_t.

What is the value returned by std::string::find()method when a search string is not found?

When no match is found, will return npos as output, which is a numerical equivalent of -1.

C++ What is the data type of the return value ofstd::string::find()? What is the value returned by std::string::find()method when a search string is not found?S

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site