How I can print to stderr in C?

后端 未结 6 1386
既然无缘
既然无缘 2020-12-23 00:11

In C, Printing to stdout is easy, with printf from stdio.h.

However, how can print to stderr? We can use fprintf to achieve it

6条回答
  •  猫巷女王i
    2020-12-23 00:50

    Do you know sprintf? It's basically the same thing with fprintf. The first argument is the destination (the file in the case of fprintf i.e. stderr), the second argument is the format string, and the rest are the arguments as usual.

    I also recommend this printf (and family) reference.

提交回复
热议问题