Incorrectly using strtol
is unnecessary; the 2nd argument is not an input, but an output i.e. it sets it to the last interpreted character. Above all, why do you want to convert the character to a long and then convert it back again to a character, when all you need is a character to print?
char ISBN[] = "3-423-62167-2";
char *p = ISBN;
while (*p)
{
if (isdigit(*p))
printf("%c", *p);
++p;
}
EDIT:
To make the whole string into a long:
unsigned long long num = 0;
while (*p)
{
if (isdigit(*p))
{
const char digit = *p - '0';
num = (num * 10) + digit;
}
++p;
}