Discussion about this post

User's avatar
Nikola Nevenov's avatar

I personally think C strings as in "null terminated" are a really good design for it's time and for non string intensive work. If you are doing string intensive work...you naturally gravitate towards some type of length based strings.Simply out of necessity to not recheck for length.

Both designs have their place in my opinion. Really depends what are you doing. Maybe there isn't a commercial software that doesn't deal a lot with strings, which makes sense why Null terminated strings could be annoying. But in that case you should have your own String container that will handle that. In which case you never touch null terminated strings.

But most of your examples all look like issues that a beginner(as in person who does not know the language) encounter. Anyone who programmed in C for a year knows what `snprintf` does, how to make sure you don't overwrite the null terminator etc...buffer overflows all the jazz.

Nick Ruisi's avatar

Every now and then I see what c/c++ is like with real-world problems and I thank God that I don't have to use it. I haven't had to worry about "C-strings" since I stopped doing native API calls for things, 20 or so years ago. I did some Robot-C about 10 years ago, but string termination never came up in that context.

12 more comments...

No posts

Ready for more?