while 判断条件返回值和判断条件赋值的问题。
astmd 2009-03-02 04:54:02 程序如下:
#include <iostream>
#include <string>
int main()
{
using namespace std;
const string str( "ab2c3d7R4E6" );
string::size_type sz1 = 0, sz2 = 0;
// 这里出现问题。
while ( ( sz2 = str.find_first_not_of( "0123456789", sz2 )) != string::npos ) {
cout << "sz2 = " << sz2 << endl;
cout << "found character at index: " << sz2
<< " element is " << str[sz2] << endl;
++sz2;
}
cout << "Done.\n";
return 0;
}
问题出现:
while判断条件( sz2 = str.find_first_not_of( "0123456789", sz2 )) != string::npos 和 ( sz2 = str.find_first_not_of( "0123456789", sz2 )) && sz2 != string::npos 有什么不同?
我在google里面没有搜到答案。麻烦各位兄弟帮我解释一下。谢谢啦!