fgets is better than getchar/scanf("%c") stuff.
You need another variable for count the digits, you use one variable for iteration and count.
Code:
#include <stdio.h>
#include <ctype.h>
#define MAX 15
int digcnt(char *x);
int main( int argc, char *argv[]) {
char x[MAX];
puts("Enter a string of chars and digits:");
fgets(x, MAX, stdin);
digcnt(x);
return 0;
}
int digcnt(char *x) {
int b,count=0;
for(b=0; x[b]!='\0'; b++) {
if(isdigit(x[b])){
count++;
}
}
printf("There are %d digits in the string.\n", count);
return count;
}