A collection of lightweight command-line utilities written in C, focused on string manipulation, pointers, buffers, and fundamental systems programming concepts.
C-TextKit is a personal learning project built to strengthen my understanding of the C programming language through practical command-line tools.
Rather than relying entirely on high-level string manipulation functions, these programs explore how strings and memory are handled at a lower level.
| Tool | Description |
|---|---|
trimcli |
Removes leading, trailing, or surrounding whitespace |
bufcopy |
Copies text into a fixed-size buffer with capacity limits |
argsplit |
Splits a string into individual arguments |
replacecli |
Performs text replacement |
heapstats |
Calculates the sum, minimum, and maximum of three integers |
- A C compiler (GCC or Clang)
- A terminal (Linux, macOS, or Windows)
Clone the repository:
git clone https://github.com/Fai707/C-TextKit.git
cd C-TextKitCompile the programs using GCC:
gcc -Wall -Wextra trimcli.c -o trimcli
gcc -Wall -Wextra bufcopy.c -o bufcopy
gcc -Wall -Wextra argsplit.c -o argsplit
gcc -Wall -Wextra replacecli.c -o replacecli
gcc -Wall -Wextra heapstats.c -o heapstatsRemoves unnecessary whitespace from text.
./trimcli " Hello World "Options:
./trimcli --left " Hello World "
./trimcli --right " Hello World "--leftremoves leading whitespace.--rightremoves trailing whitespace.- Without an option, whitespace is removed from both ends.
Copies a string into a buffer while respecting a specified capacity.
./bufcopy 6 "Hello World"Output:
[Hello]
length: 5
truncated: yes
The program reserves space for the null terminator (\0) and reports whether the original string was truncated.
Capacity must be between 1 and 256.
Splits a string into separate arguments using spaces and tabs as delimiters.
./argsplit "hello world from C"Output:
argc: 4
argv[0]: [hello]
argv[1]: [world]
argv[2]: [from]
argv[3]: [C]
Current limitations:
- Maximum input length: 255 characters.
- Maximum number of arguments: 15.
- Does not implement shell-style quoting or escaping.
Replaces text within an input string.
Syntax:
./replacecli "text" from toExample:
./replacecli "hello world" world LinuxReads three integers from standard input and calculates their sum, maximum, and minimum.
./heapstatsExample input:
10 20 30
Output:
sum: 60
max: 30
min: 10
Despite its name, the current implementation focuses on integer operations rather than heap memory statistics.
This project explores several fundamental C programming concepts:
- Pointers and pointer arithmetic: Traversing and modifying character arrays.
- String manipulation: Working with null-terminated strings.
- Buffer management: Handling fixed-size buffers and preventing out-of-bounds writes.
- Command-line arguments: Processing
argcandargv. - Input validation: Checking argument counts and accepted input ranges.
- Control flow: Implementing algorithms using loops and conditional statements.
- Functions: Separating operations into reusable pieces of code.
C-TextKit/
├── argsplit.c
├── bufcopy.c
├── heapstats.c
├── replacecli.c
├── trimcli.c
├── .gitignore
└── README.md
Each utility is implemented as an independent C program and can be compiled separately.
The main goal of C-TextKit is to develop a stronger foundation in low-level programming.
By building these utilities, I aim to improve my understanding of memory, pointers, string processing, and the design of command-line applications.
These concepts provide a foundation for more advanced projects involving Linux system programming, memory management, and operating systems.
Fai707
GitHub: github.com/Fai707