Created
January 6, 2014 14:13
-
-
Save Snigelson/8283387 to your computer and use it in GitHub Desktop.
Dynamic vsprintf
This file contains 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
/* Takes the same argumetns as vprintf. Allocates space to store the string and returns | |
* a pointer to it. | |
*/ | |
static char* dynvsprintf(char* format, va_list argp) | |
{ | |
char* buffer=NULL; | |
int length; | |
length = vsnprintf(NULL, 0, format, argp)+1; | |
buffer = malloc(length); | |
vsnprintf(buffer, length, format, argp); | |
return buffer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment