A simple C library implementing common string functions with safe behavior and extensive unit tests.
This library provides custom implementations of:
my_strcmp,my_strncmp— Compare stringsmy_strcpy,my_strncpy— Copy strings safelymy_strcat— Concatenate strings with buffer checksreverse— Reverse a string in-placemy_split— Split a string by a delimiter into a dynamically allocated array of strings
All functions handle edge cases, such as NULL pointers, empty strings, buffer size limits, and more.
.
├── include/
│ ├── my_string.h # Main library header
│ ├── common.h # Common test utilities
│ └── acutest.h # Testing framework
├── src/
│ └── main.c # Library implementations
├── tests/
│ ├── test_strcmp.c
│ ├── test_strcat.c
│ ├── test_strcpy.c
│ ├── test_strncmp.c
│ ├── test_strncpy.c
│ ├── test_reverse.c
│ └── test_split.c
├── Makefile
└── README.md
- GCC or compatible C compiler (tested on MinGW)
- Make or compatible build tool
Compile the library and build all tests:
makeOr build just the tests:
make testsRun all tests:
make run-testsRun a specific test:
make run-test TEST=test_strcmpAvailable tests: test_strcmp, test_strcpy, test_strcat, test_strncmp, test_strncpy, test_reverse, test_split
Remove build artifacts:
make cleanThis project is released under the MIT License. See LICENSE for details.