#include "stdafx.h"
#include "iostream"
#include <ctime>
using namespace std;


//getNum()获得数字字符串函数
char * getNum(char *src, char *buf)
{
    while (* src!='\0')
    {
        if (isdigit(*src))
        {
            break;
        }
        src++;
    }
    if (* src=='\0')
    {
        return '\0';
    }
    while (isdigit(*src))
    {
        *buf = *src;
         buf++;
        src++;
    }
    *buf = '\0';
    return src;
}

int _tmain()
{
    char str[100], digits[20];
    cin.getline(str, 100);
     char* p = str;
    int i = 1;
    //如果p等于空结束循环
    while ((p=getNum(p,digits))!=NULL)  
    {
        cout << "digit string " << i << " is " << digits << endl;
        i++;
    }
}

相关文章:

  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-01-01
  • 2022-01-03
猜你喜欢
  • 2022-03-11
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案