第1个回答 2015-06-05
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
unsigned long max_num(const char *str) {
unsigned long max = 0UL, i;
static const char num_string[] = "0123456789";
const char *cur = strpbrk(str, num_string);
while (cur != NULL) {
if ((i = strtoul(cur, &str, 10)) > max) max = i;
cur = strpbrk(str, num_string);
}
return max;
}
int main(void) {
printf("%lu\n", max_num("123ty#342 rre 99/*9"));
return 0;
}