string的find函数,返回下标,当不存在时返回string::npos,为无符号数最大值

来源:互联网 发布:aes java代码 编辑:程序博客网 时间:2024/04/30 14:28



#include <iostream>#include <sstream>#include <string>#include <vector>#include <stack>#include <queue>#include <map>#include <set>using namespace std;int main( void ){string str("abc");string::size_type i = str.find( "d" );cout << "i=" << i << endl;cout << "string::npos=" << string::npos << endl;// 此时i = npos = 4294967295,无符号数最大值unsigned int j = 0xffffffff;cout << "j=" << j << endl;// j = i = npos;return 0;}

运行结果——


0 0
原创粉丝点击