gpt4 book ai didi

c++ - 当搜索字符串有空格时查找字符串

转载 作者:行者123 更新时间:2023-11-28 02:07:38 25 4
gpt4 key购买 nike

<分区>

有如下代码

std::string str = "stack overflow=Ask Questions";
size_t pos = str.find("stack overflow");

if(pos != string::npos)
cout << "found" << endl; //works as expected

size_t pos1 = str.find("stack Notflow");
if(pos1 != string::npos)
cout << "found" << endl; //this is printed
else
cout << "NOt found" << endl;

在上面的代码中,如何找到“stack Notflow”?我怎样才能纠正它?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com