首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

新手请问什么是string:npos

2012-10-20 
新手请教什么是string::npos。bool URLData::extract(const char* theData){assert(theData)string theURL

新手请教什么是string::npos。
bool URLData::extract(const char* theData)
{
  assert(theData);
  string theURL(theData);

  if (theURL.find("TP:") == string::npos)
  {
  return false;
  }
  return true;
}

请问if (theURL.find("TP:") == string::npos)这个语句是要判断什么?


[解决办法]

引用楼主 ding525 的帖子:
bool URLData::extract(const char* theData)
{
assert(theData);
string theURL(theData);

if (theURL.find("TP:") == string::npos)
{
return false;
}
return true;
}

请问if (theURL.find("TP:") == string::npos)这个语句是要判断什么?

[解决办法]
简单点就是找不到"TP:"就return false

热点排行