Systems/Command-Line Utilities
46 / 67

04/2021Systems

Command-Line Utilities

Three small command-line utilities in C: a wind-chill calculator, a word printer, and a self-resizing histogram builder for streamed numbers.

╌╌╌╌

Three small command-line utilities written in C, each reading input and writing to standard output in the Unix filter style.

chill computes the wind chill from an air temperature (°F) and a wind speed (mph), using the US National Weather Service formula:

computeChill returns the value and printTable formats the output: with no arguments the program sweeps a table over temperatures from to °F and winds from to mph; given a temperature it varies wind alone, and given both it prints the single value.

words prints the words in a file one per line, reading from a named file or from standard input, scanning character by character with isalpha and emitting each run of letters as a line. histo reads a stream of integers from standard input into sixteen fixed bins; when a value overflows the current range the bin width doubles and the existing counts are merged, so the histogram rescales itself to fit the data.

References

  1. Project repository

╌╌ END ╌╌