仅此学习,留作纪念
代码如下:
#include<stdio.h>
#include<string.h>#include<malloc.h>
unsigned int Continumax (char * pOutputstr, char * intputstr)
{
if (intputstr==NULL)
{
return -1;
}
int length=strlen(intputstr);
int i,j,count=0;
int maxnum=0;
for (i=0; i<length; i++)
{
if (intputstr[i]>='0' && intputstr[i]<='9')
{
count++;
if (count>maxnum)
{
maxnum=count;
strncpy(pOutputstr,intputstr+j+1,maxnum);
}
}
else
{
count=0;
j=i;
}
}
return maxnum;
}
int main (void)
{
char inputstr[] = "abcd12345ed123sf3343461346345";
char *outputstr;
int len=strlen(inputstr);
int maxnum;
outputstr=(char *)malloc(len*(sizeof(char)));
maxnum = Continumax(outputstr, inputstr);
printf("maxnum=%d\n",maxnum);
for (int i=0; i<maxnum; i++)
{
printf("%c ",outputstr[i]);
}
printf("\n");
free(outputstr);
return 0;
}