#include<iostream>
#include<string.h>
using namespace std;
class KB
{
char *s;
public:
KB(const char *ss)
{
s=new char[strlen(ss)+1];
strcpy(s,ss);
}
void fun()
{
int num=0;
for(char *p=s;*p;p++)
if(*p>='0'&&*p<='9')
num=num*10+*p-'0';
cout<<num<<endl;
}
void print()
{
cout<<"这个字符串是:"<<s<<endl;
}
};
int main()
{
const char *w="dhn3n45nk6";
KB zk(w);
zk.fun() ;
}
c++,把一个字符串中的数字字符提取出来成为一个整数
最新推荐文章于 2023-12-06 16:40:10 发布