
例子:找到的情况
#include
#include
using namespace std;
int main()
{
string str = "aabc";
int pos = str.find("abc");
if (pos != str.npos)
{
cout << pos <
例子:找不到的情况,调试可以看到npos的值为-1,即是4294967295
#include
#include
using namespace std;
int main()
{
string str = "aabc";
int pos = str.find("d");
if (pos != str.npos)
{
cout << pos < 欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)