1 遇到的问题
int main()
{
string s = "abcbb";
if (s.find('d') < 0)
{
cout << "未找到" << endl;
}
else
{
cout << "找到" << endl;
}
}
运行程序,输出 “找到”。
2 问题答案
程序改为:
int main()
{
string s = "abcbb";
if (s.find('d') == string::npos)
{
cout << "未找到" << endl;
}
else
{
cout << "找到" << endl;
}
}
3 原因分析
https://www.cnblogs.com/pjl1119/p/8676647.html