如果find函数在sting中没有找到指定字符串则返回-1,那么为什么-1不小于string.length()图中的if语句为什么不执行?
感觉他是想判断找到了6的情况,很怪异的用法
我在我自己电脑上敲了同样的代码,没有问题啊
```string strTemp = "12345";
int nLen = strTemp.length();
int nIndex = strTemp.find("6", 0);
bool b = false;
if (nIndex < nLen)
{
b = true;
}
如果string.find(string&,startpos)找不到的话,返回的是18446744073709551615也就是string::npos这个值,赋值给int或者long long 后就会变成-1,但是实际上string::npos比a.length()大
你可以cout<<a.find("6",0)<<endl;试试