logoalt Hacker News

kccqzylast Tuesday at 3:03 PM2 repliesview on HN

Yeah but fixed width strings don’t need null termination. You know exactly how long the string is. No need to find that null byte.


Replies

ninkendolast Tuesday at 3:14 PM

Until you pass them as a `char *` by accident and it eventually makes its way to some code that does expect null termination.

There’s languages where you can be quite confident your string will never need null termination… but C is not one of them.

show 2 replies
Sharlinlast Tuesday at 3:16 PM

Good luck though remembering not to pass one to any function that does expect to find a null terminator.

show 3 replies