"When I look at the way that my predecessor wrote his code," Benedikt B wrote, "I can't help but wonder if he understood pointers as well as Kramer understood write-offs."
"The fact that our C++-based application manages to not crash for nearly a whole day is nothing short of a miracle, especially since the only decision process behind whether to use &
, *
, ::
, or –>
seemed to be whichever compiles and recovers the cleanest after a try/catch failure.
"There are so many bits I could show," Benedikt added, "but this seemed to be the perfect size for a representative line."
char* String::ToCString() { return this->Buffer+'\0'; }
"I can only guess," Benedikt continued, " but what probably happened is that said developer heard that C strings have to be null terminated. Apart from the fact that the string stored in Buffer already is null terminated, the way he decided to append a null to the end of the string is.... interesting, to say the least."
"Knowing that strings are just arrays of characters in C and confident that + means concatenation, our developer added a character constant (which is just an int) to a pointer to memory. Luckily, '\0' translates to zero, leaving the pointer unchanged and returning the (still) correctly null-terminated buffer."