习题9.38 查找字符串中的数字、字母

#include<iostream>
#include<string>

using namespace std;
//查找字符串中的数字、字母
int main(int argc,char **argv)
{
	string numerics("0123456789");
	string name = ("ab2c3d7R4E6");
	string::size_type pos = 0;
	while((pos = name.find_first_of(numerics,pos))!=string::npos)
	{
		cout<<name[pos];
		++pos;
	}
	
	pos = 0;
	while((pos = name.find_first_not_of(numerics,pos))!=string::npos)
	{
		cout<<name[pos];
		++pos;
	}
	
}

  

posted on 2011-12-04 13:58  york_software123  阅读(162)  评论(0编辑  收藏  举报

导航