Joel certainly makes string-concatenation look difficult in C.
Maybe a couple of things to add:
1) It's surprisingly easy to carry around the size of strings next to the string. Then when you do a string concat like this, you can just add up the integer amounts and you know how much to allocate.
2) While it is harder to do this kind of ad-hoc string manipulation in C than in higher-level languages, it's worth noting that "the C way" is also "the disk way". Whatever string-copying function you write in C will likely just work for files too, whereas in a higher-level language you'll probably assume your Strings are in RAM, and then write some more code to instantiate a BufferedWhatever to copy your RAM Strings onto disk.
Maybe a couple of things to add:
1) It's surprisingly easy to carry around the size of strings next to the string. Then when you do a string concat like this, you can just add up the integer amounts and you know how much to allocate.
2) While it is harder to do this kind of ad-hoc string manipulation in C than in higher-level languages, it's worth noting that "the C way" is also "the disk way". Whatever string-copying function you write in C will likely just work for files too, whereas in a higher-level language you'll probably assume your Strings are in RAM, and then write some more code to instantiate a BufferedWhatever to copy your RAM Strings onto disk.