r/cprogramming • u/Xaneris47 • Aug 17 '26
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
212
Upvotes
r/cprogramming • u/Xaneris47 • Aug 17 '26
View all comments
1
u/StudioYume Aug 21 '26
C strings were designed at a time when memory was very expensive, which is why they have the lowest possible memory overhead. But unless you're reading strings from a file or the command line, there's no reason to keep using strlen; if you're reading keys from the keyboard you can adjust the length as keys are read, and if you're modifying a string you can adjust the length as you modify it.