strange behaviour of standard C++ string library -


i started writing program findings substrings, doesn't work , found substring. strange behaviour wrote simple program:

#include <iostream> #include <string>  using namespace std;  int main(){     string str;     str = "aaaa";     unsigned found = str.find("bbbb");     if(found!=std::string::npos){         cout << "i found it!!!!\n";     }     return 0; } 

and displays text "i found it!!!!" don't understand going on.

std::string::find returns size_t

std::string::npos defined maximum value fits in size_t, 0xffffffffffffffff 64bit program.

when cast unsigned int, 32bits , 0xffffffff

as 0xffffffffffffffff != 0xffffffff result see.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -