string::npos 含义及用途

字符串查找包含某个字符串时一般通过find()查找,找到返回所在位置,找不到则会返回string::npos


示例代码:

 string  str;

 if( str.find("a") != string::npos )

 {

cout<<"找到"<<endl;

 }

 else

{

cout<<"未找到"<<endl;

}

发布了7 篇原创文章 · 获赞 0 · 访问量 4089

猜你喜欢

转载自blog.csdn.net/kk_flying/article/details/51993949
今日推荐