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
Post a Comment