From 0d2b592f08b456452eb3384f38a907b1074cb8df Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Tue, 15 May 2018 20:43:47 +0000 Subject: [PATCH] Compile with older compilers --- entropy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entropy.c b/entropy.c index 7b0244e..fb45c9c 100644 --- a/entropy.c +++ b/entropy.c @@ -7,6 +7,7 @@ main(int argc, char *argv[]) size_t len = 0; size_t hist[256] = {0}; int c; + int i; while ((c = getchar()) != EOF) { hist[c] += 1; @@ -14,7 +15,7 @@ main(int argc, char *argv[]) } float H = 0; - for (int i = 0; i < 256; i += 1) { + for (i = 0; i < 256; i += 1) { if (hist[i]) { float Hi = (float)hist[i]/len; H -= Hi * log2(Hi);