1// int sprintf(char *str, const char *format, ...);
2char *printf_to_string()
3{
4 char buffer[128] = {0} //Must be big enough
5
6 // writing printf output in buffer
7 sprintf(buffer, "some %s here...\n", "text");
8 // duplicate if needed
9 return strdup(buffer);
10}