当fail()为true时,检测未能打开一个流的原因 [英] Detecting reason for failure to open an ofstream when fail() is true
本文介绍了当fail()为true时,检测未能打开一个流的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
似乎这应该很简单,但我不会在网络搜索中找到它。
Seems like this should be simple, but I don't find it in a net search.
我有一个流的 open ()
, fail()
现在为true。我想知道无法打开的原因,像 errno
我会做 sys_errlist [errno]
。
I have an ofstream which is open()
, and fail()
is now true. I'd like to know the reason for the failure to open, like with errno
I would do sys_errlist[errno]
.
推荐答案
不幸的是,没有标准的方法来找出open()失败的原因。请注意,sys_errlist不是标准C ++(或标准C,我相信)。
Unfortunately, there is no standard way of finding out exactly why open() failed. Note that sys_errlist is not standard C++ (or Standard C, I believe).
这篇关于当fail()为true时,检测未能打开一个流的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文