C string creation from character format string? (very basic)
Posted on 2014-11-09
When using the standard library, I usually create string by using string directly or with ostringstream (<< operators)....
I like printf an awful lot though, and would love to be able to just do this if I wanted:
string s = myFormatFunction("%c%c%c%c%c", 'h', 'e', 'l', 'l', 'o');
after the call, of course, we get, "hello" in s.
There must already be a flavor of printf that does this or something similar in the standard library (c or C++)? I can't seem to find it....