#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
void remove_all_spaces(char *s) {
const char *p = s;
do {
while (*p == ' ') {
p++;
}
} while ((*s++ = *p++));
}
void print_numbers(char s[]) {
char *tmp = strdup(s);
remove_all_spaces(tmp);
int num = 0;
char *p = tmp;
while (*p) {
if (isdigit(*p)) {
num = num * 10 + strtol(p, &p, 10);
}
else {
p++;
printf("%d\n", num);
num = 0;
}
}
free(tmp);
}
int main()
{
char s[] = "1, 6472, 7, 9, 12, 899";
print_numbers(s);
return 0;
}
/*
run:
1
6472
7
9
12
*/