Added example cbd_lawn. Calculates area of yard in different units of measure.
[C-Programming-Examples.git] / countchar.c
blob20f86425e0c1083595dcf0ddd51acb05b941a9d5
1 #include <stdio.h>
3 int main()
5 int c, i, nwhite, nother, ndigit[10];
7 nwhite = nother = 0;
8 for(i = 0; i < 10; i++)
9 ndigit[i] = 0;
10 while((c = getchar()) != EOF)
12 switch(c)
14 case '0': case '1': case '2': case '3': case '4':
15 case '5': case '6': case '7': case '8': case '9':
16 ndigit[c-'0']++;
17 break;
18 case ' ': case '\n': case '\t':
19 nwhite++;
20 break;
21 default:
22 nother++;
23 break;
26 printf("digits =");
27 for(i =0; i < 10; i++)
28 printf(" %d", ndigit[i]);
29 printf(", white space = %d, other = %d\n", nwhite , nother);
30 return 0;