Skip to content

Instantly share code, notes, and snippets.

@rlabbe
Created December 4, 2018 22:48
Show Gist options
  • Save rlabbe/88598abfd04295831e825800f224fec7 to your computer and use it in GitHub Desktop.
Save rlabbe/88598abfd04295831e825800f224fec7 to your computer and use it in GitHub Desktop.
putf implementation
#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