The joy of C++ streams

Many programmers complain about how poorly C++ handles strings. The unfortunate reality is that a language with such direct memory access as C++ can’t realistically handle variable-length strings natively. This is because stack memory usage absolutely must be fixed at compile-time. Or, in simpler terms, you can’t expect to fit an unpredictably large peg into a small hole. The std::string class improves things considerably. It is a very robust and efficient string class which is about as close to a native string as you’re likely to get. It still doesn’t solve all our problems though. For example, it doesn’t always do string concatenation very well, and it’s not always easy to convert other types (such as numbers) to a std::string. Thankfully, streams come to our rescue! They provide a beautifully simple and straightforward means of building up strings of text and sending them pretty much wherever we need them. Read more The joy of C++ streams