C++字符串和字符串文字比较
C++ string and string literal comparison
所以我试图简单地做一个可以正常工作的std::string == "string-literal"
,除了我正在创建我的字符串
std::string str(strCreateFrom, 0, strCreateFrom.find(' '));
并找到返回string::npos
现在这两个都包含字符串"submit"
但是==
返回 false,现在我已将其缩小到大小"不同"的事实,即使它们实际上不是。 str.size()
是 7,strlen("submit")
是 6。这就是==
失败的原因吗,我想是,但我不明白为什么......它不应该检查 DIF 的最后一个字符是否像在这种情况下那样