写一个函数,它的原形是int continumax(char *outputstr,char *intputstr)
功能:
在字符串中找出连续最长的数字串,并把这个串的长度返回,
并把这个最长数字串付给其中一个函数参数outputstr所指内存。
例如:"abcd12345ed125ss123456789"的首地址传给intputstr后,函数将返回9,
outputstr所指的值为123456789
int continumax(char *outputstr, char *intputstr) { int i, maxlen = 0; char* maxstr = 0; while (true) { while (intputstr && (*intputstr<'0' || *intputstr>'9')) //skip all non-digit characters { intputstr++; } if (!intputstr) break; int count = 0; char* tempstr = intputstr; while (intputstr && (*intputstr>='0' && *intputstr<='9')) //OK, these characters are digits { count++; intputstr++; } if (count > maxlen) { maxlen = count; maxstr = tempstr; } } for (i=0; i<maxlen; i++) { outputstr[i] = maxstr[i]; } outputstr[i] = 0; return maxlen; }