在使用string时有两点需要注意.不然全发生让你莫名其妙的错误,而摸不着头脑
1.给一个string对象赋值时,千万不要赋空指针字符.不然,准叫你崩溃
2.在使用find查找一个子字符串时,如果被查找的字符为空,则返回0的位置,而不是sring::npos
比如:
string strOr("limit"
);
string strFind; //空的
string::size_type pos = strOr.find(strFind);
或string::size_type pos = strOr.find("" );
string strFind; //空的
string::size_type pos = strOr.find(strFind);
或string::size_type pos = strOr.find("" );
此时pos等于0,而不是string::npos.以前一直以为是string::npos呢