#include "header.h" int Counts[256]; int main(){ //time_t start, stop; // time() version clock_t start, stop; // clock() version unsigned char uc; int i; //Start Timer //time(&start); // time() version start = clock(); // clock() version // Get input and count // scanf returns one untill it fails at EOF and returns 0 while((scanf("%c",&uc)) > 0){Counts[uc]++;} //Stop Timer //time(&stop); // time() version stop = clock(); // clock() version //Printing Output //Formatted differently for printable 32-127 for(i=0;i<32;i++){ if(Counts[i]!=0){ printf("%d\t\t%d\n", i, Counts[i]); } } for(i=32;i<128;i++){ if(Counts[i]!=0){ printf("%d\t%c\t%d\n", i, i, Counts[i]); } } for(i=128;i<256;i++){ if(Counts[i]!=0){ printf("%d\t\t%d\n", i, Counts[i]); } } //Printing timing //printf("\nElapsed time = %g Seconds\n", difftime(stop, start)); // time() version printf("\nElapsed time = %g Seconds\n", (stop-start)/((float) CLOCKS_PER_SEC)); // clock() version return 0; }