Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 什么是C++;相当于perror的流?_C++ - Fatal编程技术网

C++ 什么是C++;相当于perror的流?

C++ 什么是C++;相当于perror的流?,c++,C++,可能重复: 我找不到与peror等效的流。有这样的事吗?我喜欢我可以打电话给: perror("Error"); 它将填充errno是什么。我可以用streams执行此操作吗?要打印错误消息: str << strerror(errno); STR 自从 PrRor 写到STDRR,C++中的任何等价物都必须完全相同。也就是说,仅将strerror(errno)写入流是不够的。流本身应该(我认为必须)是流到标准错误 下面的代码段/伪代码应该会让您有所了解: // depend

可能重复:

我找不到与
peror
等效的流。有这样的事吗?我喜欢我可以打电话给:

perror("Error");

它将填充
errno
是什么。我可以用streams执行此操作吗?

要打印错误消息:

str << strerror(errno);

<代码> STR

自从<代码> PrRor 写到STDRR,C++中的任何等价物都必须完全相同。也就是说,仅将

strerror(errno)
写入流是不够的。流本身应该(我认为必须)是流到标准错误

下面的代码段/伪代码应该会让您有所了解:

// 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;
//根据编译器的不同,这是您需要包含的全部内容
#包括
#包括
#包括
... 在代码的某个地方。。。

艾瑞克:是的!。。。我以前见过这个函数,但我再也想不出来了。谢谢