读书人

新手请问什么是string:npos

发布时间: 2012-10-20 14:12:48 作者: rapoo

新手请教什么是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

读书人网 >C++

热点推荐