How do I perform string formatting to a static buffer in C++?
问题 I am working in a section of code with very high performance requirements. I need to perform some formatted string operations, but I am trying to avoid memory allocations, even internal library ones. In the past, I would have done something similar to the following (assuming C++11): constexpr int BUFFER_SIZE = 200; char buffer[BUFFER_SIZE]; int index = 0; index += snprintf(&buffer[index], BUFFER_SIZE-index, "Part A: %d\n", intA); index += snprintf(&buffer[index], BUFFER_SIZE-index, "Part B: