c - 哪个更好 - printf 或 fprintf

标签 c printf output

我知道这两个函数都可以用来输出到控制台。
我读了that question , 但没有人不知道在输出到控制台时首选使用哪个。 那么哪个功能更好,有什么大的区别吗?

最佳答案

引用标准(n1570中的7.21.6.3):

The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.

所以printf打印到控制台的时候比较方便,否则没有区别。但如果您想更改输出目标,fprintf 更容易修改。

关于c - 哪个更好 - printf 或 fprintf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13261879/

相关文章:

c - 为什么输出是 “In foo, a = 7”?

c - 是否有限定符将 C 指针指示为 'given to you and should be freed by you' ?

c - 如何将用户在 C 中输入的字符传递给 printf?

php - 如何在 PHP mail() 中将文本设为粗体?

output - 专门为不打印奎因而构建的语言仍然是图灵完整的吗?

在c中复制一个bmp

c++ - 头文件包含和性能注意事项 c++

c - 使用 sprintf 和 PQexecParams 重用缓冲区指针

c - 执行 printf 时 %p 的结果不正确

C++ 字符串在多行上打印