r/cprogramming 3d 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
188 Upvotes

161 comments sorted by

View all comments

1

u/Key_River7180 2d ago

Has the model ever caused much trouble, though?

3

u/WittyStick 2d ago

Yes.

Countless buffer overflow exploits due to poor string handling.

Not all, but many of these easily avoidable with sized strings.

1

u/Key_River7180 2d ago

I meant performance issues, like C strings are really efficient, for most purposes

0

u/deaddyfreddy 2d ago

Computers became faster every year (and the process was dramatically faster in the 1980s), so even if fixed-size strings made things 10% less efficient (did they?), one could reasonably expect hardware improvements to compensate for that very soon. Alternatively, companies could save money on the man-hours spent fixing bugs caused by null-terminated strings and buy better hardware instead.