📜  C printf to string - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:33.910000             🧑  作者: Mango

代码示例1
// int sprintf(char *str, const char *format, ...);
char *printf_to_string()
{
  char buffer[128] = {0} //Must be big enough

  // writing printf output in buffer
  sprintf(buffer, "some %s here...\n", "text");
  // duplicate if needed
  return strdup(buffer);
}