Created
December 4, 2018 22:48
-
-
Save rlabbe/88598abfd04295831e825800f224fec7 to your computer and use it in GitHub Desktop.
putf implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdarg.h> | |
// simple implementation of the proposed std::putf | |
// int i = 3; | |
// auto d = 3.1415926; | |
// cout << putf("%03di -> %.3f", i, d) << endl; | |
std::string putf(const char* format, ...) | |
{ | |
va_list args; | |
va_start(args, format); | |
char str[4096]; | |
vsprintf_s(str, 4096, format, args); | |
va_end(args); | |
return std::string(str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment