string::npos 含义及用途

字符串查找包含某个字符串时通常经过find()查找,找到返回所在位置,找不到则会返回string::nposspa 示例代码:字符串  string  str;string  if( str.find("a") != string::npos )co  {字符 cout<<"找到"<<endl;  }  else { cout<<"未找到"<<endl; }
相关文章
相关标签/搜索