问题描述
|
这个问题已经在这里有了答案:
解决方法
要打印错误消息:
str << strerror(errno);
如果您正在谈论流错误状态-不,您将无法获得自动有意义的错误消息。
,由于ѭ1写入stderr,因此C ++中的任何等效项都必须完全相同。即,将“ 2”写入流是不够的。流本身(应该说是必须)是标准错误的流。
以下代码段/伪代码应该给您一个提示:
// depending on your compiler,this is all you need to include
#include <iostream>
#include <string.h>
#include <errno.h>
... somewhere in your code...
std::cerr << \"Error: \" << strerror(errno) << std::endl;