r/cprogramming • • 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

172 comments sorted by

View all comments

Show parent comment

3

u/Classic_Department42 Aug 18 '26

Missing a *?

1

u/bearheart Aug 18 '26

No. A C-string is char*

3

u/Classic_Department42 Aug 18 '26

Yes, so while (s) shd prob be while(*s) ?

2

u/bearheart Aug 18 '26

Oy! You’re right. How did I miss that 🤦 fixed it.

1

u/No-Newspaper8619 Aug 20 '26

Good thing that has been pointed out

1

u/Quote_Revolutionary Aug 20 '26

this is the beauty of C: while trying to show how it's actually ergonomic one writes UB because the correct form has to be very precise, btw your idiom would compile...