New printy command

This commit is contained in:
Neale Pickett 2023-11-15 13:13:47 -07:00
parent 16ac8bd6ac
commit fb2cc4c44d
1 changed files with 23 additions and 0 deletions

23
printy.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <ctype.h>
int main(int argc, char *argv[]) {
int c;
unsigned int count = 0;
unsigned int printy = 0;
for (;;) {
c = getchar();
if (EOF == c) {
break;
}
if (isprint(c)) {
printy += 1;
}
count += 1;
}
printf("%f\n", printy/(float)count);
return 0;
}