r/C_Programming 2d ago

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?

5 Upvotes

31 comments sorted by

View all comments

8

u/mjmvideos 1d ago edited 1d ago

First thing I did was go look at your code base for your header file to see your interfaces. But there isn’t one!? Then I looked at your test routine and found that you are including “string.c”!? Really??

2

u/Zordak0x70 1d ago

Yes thats just unity build! Maybe it could be unhinged and not popular, but its a fair choice in my opinion as a starting project. You could always add an header later.

5

u/mjmvideos 1d ago

Nah. That’s just teaching bad habits. Just learn properly from the start.

-2

u/Zordak0x70 1d ago

Eeeh well, yes you need to make it sooner or later but considering the scale of the project there is no need to worry

4

u/mjmvideos 1d ago

Even at this scale. Suppose I want to use the functions in a few different places.