All pastes #516932 Raw Edit

Stuff

public text v1 · immutable
#516932 ·published 2007-05-28 22:09 UTC
rendered paste body
#include <stdio.h>
#include <string.h>
int main()
{
   FILE *fin;
   int num[93] = {0};
   int ch, i, filename[25];
   printf("Filename: ");
   fgets(filename, sizeof(filename), stdin);
   filename[strcspn(filename), "\n")] = 0x00;
   if ((fin = fopen(filename, "r")) == NULL) {
      printf("Error\n");
      return 1;
   }
   while ((ch = fgetc(fin)) != EOF) {
      if (ch > 33 && ch < 126) num[ch - 33]++;
   }
   for (i = 0; i < 93; i++) {
      printf("%c %d\t", i + 33, num[i]);
      if ((i + 1) % 5 == 0) printf("\n");
   }
   fclose(fin);
   getche();
   return 0;
}