Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • The correct way to use find is if (para2.find(".jpg") != std::string::npos) Commented Nov 25, 2013 at 11:53
  • Yes, the return value is size_t type, it is a unsigned int. If no matches were found, the function returns string::npos. It does not mean string::npos is 0, you should use string::npos to check. Commented Nov 25, 2013 at 11:56
  • Oh, of course. string::npos is a very large positive number! I overlooked that too. And in fact, the test para2.find(".jpg") would return 0 if the string was equal to ".jpg" Commented Nov 25, 2013 at 19:15
  • std::string::npos should be equal to (std::size_t)-1 which is 0xFFFFFFFF. Commented Nov 25, 2013 at 19:46