A friend's number came with dashes, spaces and brackets. Write count_digits(phone) to count only the characters from '0' to '9'; everything else is skipped. An empty string gives 0.
count_digits("138-0013-8000")→11count_digits("")→0int count_digits(const char *phone)int count_digits(const char *phone) {
int n = 0;
for (int i = 0; phone[i] != '\0'; i++) {
// your code here: if it is between '0' and '9', add 1 to n
}
return n;
}
Run tries the examples. When they look right, Submit.