charCounter is a lightweight C utility designed for basic text analysis. It reads a text file character-by-character and provides statistics on characters and words, including unique word detection and word frequencies.
- β Character counting
- β Word tokenization based on space and newline
- β Hash table-based word frequency tracking
- β Unique word listing
- β Console and file output support
- β Lightweight and modular code
The program uses fgetc() to read characters from a file and builds words dynamically. These words are inserted into a hash table for tracking frequency. Once the file is parsed, it prints:
- Each character (if enabled)
- Words as they are formed
- A list of all unique words (words occurring only once)
The program is controlled using flags:
-cβ Enables character counting-wβ Enables word parsing and frequency tracking
You can configure the behavior based on which flags are set in the code.
Compile Instructions:
make all
make installThe charCounter utility supports the following command-line flags:
| Flag | Long Option | Description |
|---|---|---|
-h |
--help |
Show the help message |
-v |
--version |
Show the program version |
-f <file> |
--file |
Specify the input file to read from |
-o <output> |
--output |
Specify the output file to write to |
-c |
Analyse the Characters | |
-w |
Analyse the Words |
charCounter -f input.txt -o output.txt