/****************************************************************/ /* */ /* Collect file statistics */ /* */ /* Public domain demo program for analyzing encrypted */ /* files. By: Bob Stout */ /* */ /****************************************************************/ #include #include #include #include main(int argc, char *argv[]) { int i, ch, hist = 0; long n = 0L; double mean = 0., stdev = 0., ftmp; static unsigned bins[256]; FILE *infile; assert(infile = fopen(argv[1], "rb")); while (!feof(infile)) { if (EOF == (ch = fgetc(infile))) break; bins[ch] += 1; ++n; } fclose(infile); for (i = 0; i < 256; ++i) { mean += (double)(bins[i]); if (bins[i]) ++hist; } mean /= 256.; for (i = 0; i < 256; ++i) { ftmp = (double)(bins[i]) - mean; stdev += (ftmp * ftmp); } ftmp = stdev / 255.; stdev = sqrt(ftmp); printf("%ld Characters were read from %s\n" "There are an average of %f occurances of each character\n" "%d Characters out of 256 possible were used\n" "The standard deviation is %f\n" "The coefficient of variation is %f%%\n", n, argv[1], mean, hist, stdev, (100. * stdev) / mean); return EXIT_SUCCESS; } 0d6ed883ba193b314'>treecommitdiff
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2014-01-04 14:20:04 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-08 15:36:18 -0800
commit9705710e40b9e5acaf003f90d6ed883ba193b314 (patch)
treedfb384987edfd08ab4eeec257657a48871b89adf /lib/kobject.c
parenteb4c69033fd1dda8b60e48af3accdd578c2e59ed (diff)
kobject: Fix source code comment spelling
Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/kobject.c')