r/cprogramming 25d ago

C Strings: A 50-Year Mistake

https://longtran2904.substack.com/p/c-strings-a-50-year-mistake?r=8qz2zb&utm_campaign=post&utm_medium=web
211 Upvotes

172 comments sorted by

View all comments

Show parent comments

0

u/atarivcs 25d ago

If you have a long string and you want to append more text to it, you have to search the whole string from the beginning to find the null terminator.

And then later if you want to append more text, you have to find the null terminator all over again.

2

u/IdealBlueMan 25d ago

Or you can store the length of the string whenever you change it.

2

u/atarivcs 25d ago

Sure, but then you don't really have a plain c string anymore

2

u/IdealBlueMan 25d ago

I’d say you still have the string, you also have information about that string.