在python中,当一个字符不在字符串'-1'时返回:
a = "hello"
a.find("a")
Run Code Online (Sandbox Code Playgroud)
结果: -1
但在C++中它返回一个奇怪的数字!!!:
string a;
a = "hello";
a.find("a");
Run Code Online (Sandbox Code Playgroud)
结果: 4294967295
这是什么?它是否适用于所有字符串中的所有字符??? 我怎么能说一个特殊的字符串不在文本中做一些工作?
我在python中知道但不是在C++中...
std::string::npos当没有成立时,它会返回string.std::string::npos由标准定义
static const size_type npos = -1;
Run Code Online (Sandbox Code Playgroud)