This is program is used to let you filter, transform, and summarize the contents of any plain‑text file. It demonstrates robust file‑I/O, dynamic memory management, and plug‑and‑play “operations” implemented with function pointers and configuration structs.
| Menu Option | Capability | Process |
|---|---|---|
| 1 · Filter lines | Keep lines that do not contain a user‑supplied keyword | Two‑tier loop + keyCheck() to drop matches |
| 2 · Transform lines | U → convert every line to uppercase R → reverse each line |
Action dispatched through TransformConfig |
| 3 · Summarize lines | • total line count • frequency of a target word (case‑insensitive) • average line length |
Uses helper countKeyword() & on‑the‑fly stats |
| 4 · Exit | Quit safely, freeing all heap memory | freeLines() cleans up |
Every processed result is immediately written to the output file you specify.
Windows User:
- Download VS Code and C/C++ Extension in VS Code.
- Download MinGW. Link: https://sourceforge.net/projects/mingw/
- In Terminal, type
gcc main.c operation.c fileProcessing.c -o text-toolkit.exefor compile the program and build the executable. - In Terminal, type
.\text-toolkit.exeto run the program.
Mac User:
- Open Terminal, type
xcode-select --installto install the Command Line Tools. - In Terminal, type
gcc main.c operation.c fileProcessing.c -o text-toolkitfor compile the prgram and build the executable. - Lastly, type
./text-toolkitto run the program.
-
Loose coupling via function pointers
typedef char **(*funcPtr)(char **, int, void *, int *);- allows new operations to drop in without touching main.c.
-
Memory‑safe patterns All heap allocations checked; buffers sized with strlen + 1; interactive input trimmed with newline guards.
-
Cross‑platform build flags -Wall -Wextra -std=c11 keeps the code standards‑compliant and warning‑free.
-
Clear separation of concerns
-
I/O layer: fileProcessing.*
-
Domain logic: operations.*
-
UI + flow control: main.c
-