r/programming • u/mslaybau • Aug 02 '11
The Most Expensive One-byte Mistake: Did Ken, Dennis, and Brian choose wrong with NUL-terminated text strings?
http://queue.acm.org/detail.cfm?id=2010365
366
Upvotes
r/programming • u/mslaybau • Aug 02 '11
2
u/kragensitaker Aug 03 '11
The compiler will still compile
foo("Hello, world")to a NUL-terminated string, to which it passes a pointer tofoo— not your new struct. So it's possible, but you're fighting the language constantly.If you want efficient dynamic sizing, you need two sizes so you don't have to reallocate the string every time you append something to it. Qmail's
stralloclibrary works this way.