Re-writing string.h for learning and fun.
There is no string data structure in the C programming language. There are arrays of type char. And the string.h library is a library that allows you to do some operations on these char arrays.
- It does not depend standard C library
- Binary size is too small
- It has easy-readable and short code
- It distributed with BSD-3-Clause license
- mstrlen
- mstrcmp
- mstrcpy
- mstrchr
- mstrstr
- mstrncmp
- mstrncpy
- mstrcat
- mstrncat
- mmemcpy
- mmemcmp
- mmemmove
- mmemset
- mstrrchr
- mmemchr
Function headers can be seen in the mstrutils.h file.
make
make installThis command creates the libmstr.so file and copies it into ~/.local/lib/
If you can't compile or run your code with this library, check out the Troubleshooting section at the end of the README.
To use functions, you can add the text #include <mstrutils.h> to the top of your code.
While compiling your code with this library, use -lmstr flag
Sometimes your system can't see ~/.local/lib/ for libraries. If you can use root, you can type
make
sudo make install PREFIX=/usr/localBut if you can't do this, add this to your .bashrc:
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$HOME/.local/lib:$LIBRARY_PATH
export C_INCLUDE_PATH=$HOME/.local/include:$C_INCLUDE_PATHAnd run this command:
source ~/.bashrcThanks for reading.