Reputation: 6240
So it is tempting to do this:
char buf[1024] = "this is";
std::sprintf(buf, "%s test", buf);
But it is undefined behaviour. I suppose it can be solved via temporary:
char buf[1024] = "this is";
std::sprintf(buf, "%s test", std::string(buf).c_str());
What are the downsides of this approach?
Upvotes: 2
Views: 1431