• Advertisement
Sign in to follow this  

what does npos mean?

This topic is 4875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

the book im using is showing me string::npos but it does not give a thorough explanation could someone give me a thorough explanation .

Share this post


Link to post
Share on other sites
Advertisement
it's an enumeration (for -1, as I recall). basically, it's shorthand for "this wasn't found anywhere in the string"

Share this post


Link to post
Share on other sites
"The largest possible value of type size_type. That is, size_type(-1)", where size_type is "an unsigned integral type." Therefore, npos is the "rollover" value of that unsigned type. It serves to indicate an index that std::string cannot support, and many indexing methods return it to indicate "end of string".

Share this post


Link to post
Share on other sites
In VC.NET, npos is defined as a "static const size_type npos = -1", which indicates a non-position. It is returned when a find function fails.

[edit] damn!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement