fork download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <ctype.h>
  4.  
  5. int main(){
  6. char buff[4096];
  7. size_t i,sz;
  8. uintmax_t numeric = UINTMAX_C(0);
  9. uintmax_t alphabet = UINTMAX_C(0);
  10. uintmax_t other = UINTMAX_C(0);
  11.  
  12. for(;;){
  13. sz = fread( buff, 1, sizeof(buff), stdin );
  14. if( sz == 0 ) break;
  15. for( i = 0; i < sz; ++i ) {
  16. if( isalpha( buff[i] )) {
  17. ++alphabet;
  18. }
  19. else if( isdigit( buff[i] )) {
  20. ++numeric;
  21. }
  22. else {
  23. ++other;
  24. }
  25. }
  26. }
  27.  
  28. printf( "num=%ju, alpha=%ju, other=%ju\n", numeric, alphabet, other );
  29. }
  30.  
Success #stdin #stdout 0.01s 1724KB
stdin
th1s 1s test c0de!
stdout
num=3, alpha=11, other=4