// 0938.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <string> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string str("ab2c3d7r4e6"); string strNumber("0123456789"); string::size_type pos = 0; while ( (pos = str.find_first_of(strNumber,pos)) != string::npos ) { cout << "found number at index: " << pos << " element is " << str[pos] << endl; ++pos; } return 0; } // 093802.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <string> #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string str("ab2c3d7r4e6"); string strNumber("0123456789"); string::size_type pos = 0; while ( (pos = str.find_first_not_of(strNumber,pos)) != string::npos ) { cout << "found number at index: " << pos << " element is " << str[pos] << endl; ++pos; } return 0; }