fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. int main(void)
  5. {
  6. int c;
  7. int counts[26] = {0};
  8. c = getchar();
  9. while (c != EOF)
  10. {
  11. if (isalpha(c))
  12. counts[(toupper(c)-'A')]++;
  13. c = getchar();
  14. }
  15.  
  16. for (unsigned int i = 0; i < sizeof(counts)/sizeof(counts[0]); i++)
  17. {
  18. if (counts[i] !=0 )
  19. printf("%c: %d\n", 'A'+i, counts[i]);
  20. }
  21.  
  22. return EXIT_SUCCESS;
  23. }
Success #stdin #stdout 0s 2116KB
stdin
The quick brown fox jumps over the lazy dog.
stdout
A: 1
B: 1
C: 1
D: 1
E: 3
F: 1
G: 1
H: 2
I: 1
J: 1
K: 1
L: 1
M: 1
N: 1
O: 4
P: 1
Q: 1
R: 2
S: 1
T: 2
U: 2
V: 1
W: 1
X: 1
Y: 1
Z: 1