With all this talk about char* and the struct hack, some of you may have gotten the (incorrect) impression that I hate C-strings. On the contrary, I think they're great. Many of my friends are character buffers! In fact, one of my favorite functions is strdupa. But with std::strings and StringBuffers out there, how can they compete?
Luckily Ben, one of our field agents, has found a good example of when a StringBuffer is overkill. Apparently, it was too much trouble to type TextToPrint[Index]=sb.ToString().
While Index<IndexN
sb.Append("\nDEFAULT");
TextToPrint[Index] = sb.ToString();
sb.Remove(0, sb.Length);
Index++;
End While
Still, there is a lot of care that must be taken when working with null-termination. Dima found the following code, which exists "just to make sure there is no null left behind."
strcpy( buffer, string);
strcat( buffer, "\0");
With all the bad press, many character arrays have gone in to hiding. With functions like strfry out there, I can't say I blame them. That's when it's time to hire maintenance programmers (like Roman) to hunt them down and bring them in, alive or permuted.
char * response = /* "HTTP/1.0 200 OK\r\n"; /*
char * response = */ "HTTP/1.0 302 Moved Temporarily\r\n"; /*
char * response = /* "HTTP/1.%d 302 Found\r\n"; /*
*/