fork download
  1. ```
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. void count_characters() {
  6. char text[100];
  7. printf(": ");
  8. fgets(text, 100, stdin);
  9.  
  10. int char_count[26] = {0};
  11. for (char *p = text; *p; p++) {
  12. if (isalpha(*p)) {
  13. char_count[tolower(*p) - 'a']++;
  14. }
  15. }
  16.  
  17. printf(": \n");
  18. for (int i = 0; i < 26; i++) {
  19. if (char_count[i]) {
  20. printf("%c: %d\n", i + 'a', char_count[i]);
  21. }
  22. }
  23. }
  24.  
  25. int main() {
  26. count_characters();
  27. return 0;
  28. }
  29. ```
Success #stdin #stdout 0.03s 25684KB
stdin
Standard input is empty
stdout
```
#include <stdio.h>
#include <ctype.h>

void count_characters() {
    char text[100];
    printf(": ");
    fgets(text, 100, stdin);

    int char_count[26] = {0};
    for (char *p = text; *p; p++) {
        if (isalpha(*p)) {
            char_count[tolower(*p) - 'a']++;
        }
    }

    printf(": \n");
    for (int i = 0; i < 26; i++) {
        if (char_count[i]) {
            printf("%c: %d\n", i + 'a', char_count[i]);
        }
    }
}

int main() {
    count_characters();
    return 0;
}
```