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

c++查找函数find()错误

2013-02-18 
c++查找函数find()异常//代码如下//#include iostream#include stringusing namespace stdint main()

c++查找函数find()异常
//代码如下//
#include <iostream>
#include <string>
using namespace std;

int main()
{
string name("the catche rin the rye");
string::type_size p=name.find("rye");
if(p=string::npos)
{
cout<<"the rye couldn't be find"<<endl;

}

else
cout<<"the rye find at p="<<p<<endl;
system("pause");
return 0;



}
//编译没错,但输出"the rye counldn't be find"//
[解决办法]
下次吧string::npos写前面,如果忘了就会报错。
[解决办法]
单步调试和设断点调试是程序员必须掌握的技能之一。

热点排行