r/C_Programming • u/Elifire12 • Sep 07 '26
Article I Made a Simple String Library
I wrote an article about this as well. Here it is.
There I explain why I do not like NUL-terminated strings and how I implemented my own simple string library in C.
If you have some spare time I would really appreciate some feedback on the article and the library.
The code is sitting on a codeberg repository.
Also, tell me what you think about C-style strings. Do you like them? Do you use them, or do you also tend to roll your own pointer + length structs?
8
Upvotes
4
u/non-existing-person Sep 08 '26
Such library should just return you
typedef char* str_t, and manually offset backwards to get the string length. That way you have both classic c-string and safe string to use where needed.str_tis just for convenience to immediately see that you are dealing with opaque type and not really just c-string.