char *printf_to_string() { char buffer[128] = {0} sprintf(buffer, "some %s here...\n", "text"); return strdup(buffer); }