What are “cerr” and “stderr”?

前端 未结 2 1139
臣服心动
臣服心动 2021-02-06 23:06

What is the difference between them and how are they used? Can anyone point me to examples?

Specifically, how do you \"write\" to the stream in both cases and how do you

2条回答
  •  北荒
    北荒 (楼主)
    2021-02-06 23:22

    What is the difference between them

    stderr is a FILE*, and part of the standard C library. cerr is an ostream, and part of the standard C++ library.

    Also, the "screen" output is itself a stream right?

    Yes, it is. But there are actually two streams that write to the screen by default: stdout/cout is for normal output and stderr/cerr is for error messages. This is useful for redirection: You can redirect stdout to a file but still have your error messages on the screen.

提交回复
热议问题