r/C_Programming • • 15d ago

Tiny strings

https://napcakes.nekoweb.org/posts/tiny-strings/
31 Upvotes

13 comments sorted by

View all comments

2

u/8d8n4mbo28026ulk 13d ago edited 13d ago

Re: C strings. In a timely event, u/skeeto just found a bug in Bash due to NUL.

The design of C strings actually admits how important it is to keep the length. You always want to know the length, and C strings "solve" that problem by appending a '\0'. That decision makes them non-recursive and from there stem all their problems. (Pascal strings suffer from this too, but atleast you can do bound checks).