Compile with older compilers

This commit is contained in:
Neale Pickett 2018-05-15 20:43:47 +00:00
parent a95481626c
commit 0d2b592f08
1 changed files with 2 additions and 1 deletions

View File

@ -7,6 +7,7 @@ main(int argc, char *argv[])
size_t len = 0; size_t len = 0;
size_t hist[256] = {0}; size_t hist[256] = {0};
int c; int c;
int i;
while ((c = getchar()) != EOF) { while ((c = getchar()) != EOF) {
hist[c] += 1; hist[c] += 1;
@ -14,7 +15,7 @@ main(int argc, char *argv[])
} }
float H = 0; float H = 0;
for (int i = 0; i < 256; i += 1) { for (i = 0; i < 256; i += 1) {
if (hist[i]) { if (hist[i]) {
float Hi = (float)hist[i]/len; float Hi = (float)hist[i]/len;
H -= Hi * log2(Hi); H -= Hi * log2(Hi);