fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int count[256];
  5. for (int i = 0 ; i != 256 ; count[i++] = 0);
  6. char *str = "AACDBACBAabcAcddaAABD";
  7. for (char *p = str ; *p ; count[(int)*p++]++);
  8. char array_values[] = { 'A','B','C','D','a','b','c','d' };
  9. for (int i = 0 ; i != 8 ; i++) {
  10. printf("Found '%c' %d times\n", array_values[i], count[(int)array_values[i]]);
  11. }
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
Found 'A' 7 times
Found 'B' 3 times
Found 'C' 2 times
Found 'D' 2 times
Found 'a' 2 times
Found 'b' 1 times
Found 'c' 2 times
Found 'd' 2 times