Created
October 10, 2017 21:16
-
-
Save bagder/ae5c1ec74560f2f4590401befdc5b490 to your computer and use it in GitHub Desktop.
Test program for comparing sprintf() implementations
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 <stdio.h> | |
#include <string.h> | |
#include <curl/curl.h> | |
#include <curl/mprintf.h> | |
#define RUNS 10000000 | |
/*#define curl_msnprintf snprintf*/ | |
int main(int argc, char **argv) | |
{ | |
int i; | |
char buffer[256]; | |
const char *string1 = "this is the first string"; | |
const char *string2 = "but what about this then?"; | |
for(i=0; i<RUNS; i++) { | |
curl_msnprintf(buffer, sizeof(buffer), | |
"%s %3d %4s %-3d %c and some text on that\n", | |
string1, | |
2017, | |
string2, | |
192, | |
'#'); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment