为什么流失败()位设置? [英] Why is stream fail() bit set?

查看:116
本文介绍了为什么流失败()位设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这件事让我疯狂。


为什么这样的简单输出文件流:


ofstream ofs;

ofs.open(" c:\ temp \ somefile.txt")


设置失败位?


在打开后立即调用ofs.fail()返回true。


This thing is driving me nuts.

why would a simple output file stream like this:

ofstream ofs;
ofs.open("c:\temp\somefile.txt")

set the fail bit?

calling ofs.fail() right after the open is returning true.

推荐答案

你好,


\ t

表示tabstop

使用

c:/ temp / somefile。 txt



c:\\ temp \\somefile.txt


-

问候,Ron AF Greve

http://moonlit.xs4all。 nl


" Dilip" < rd ***** @ lycos.com写信息

news:11 ********************** @ m73g2000cwd。 googlegr oups.com ...
Hi,

\t
means tabstop
use either
c:/temp/somefile.txt
or
c:\\temp\\somefile.txt

--
Regards, Ron AF Greve

http://moonlit.xs4all.nl

"Dilip" <rd*****@lycos.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...

>

这件事让我疯狂。


为什么一个简单的输出文件流是这样的:


ofstream ofs;

ofs.open(" c:\ temp\somefile。 txt")


设置失败位?


在打开后返回true时调用ofs.fail()。
>
This thing is driving me nuts.

why would a simple output file stream like this:

ofstream ofs;
ofs.open("c:\temp\somefile.txt")

set the fail bit?

calling ofs.fail() right after the open is returning true.





Moonlit写道:

Moonlit wrote:




\ t

表示tabstop

使用

c:/temp/somefile.txt



c:\\ temp \\somefile.txt
Hi,

\t
means tabstop
use either
c:/temp/somefile.txt
or
c:\\temp\\somefile.txt



这只是一个例子。我知道字符串中的反斜杠需要转义
。该文件确实已创建。它只是因为我无法写入

,因为fail()返回true而我无法找出原因。
低级操作系统_open(或者其他)呼叫似乎每次成功创建

文件。在那之后的某个地方,我不知道为什么那一点是

设定。

That was just an example. I know a backslash inside a string needs to
be escaped. The file does get created. Its just that I can''t write
anythng into it because fail() returns true and I can''t figure out why.
The low level OS _open (or whatever) call seems to successfully create
the file everytime. Somewhere after that I don''t know why that bit is
getting set.


Dilip写道:
Dilip wrote:

这件事让我疯狂。


为什么这样的简单输出文件流:


ofstreams;

ofs.open(" c:\ temp\somefile.txt")
This thing is driving me nuts.

why would a simple output file stream like this:

ofstream ofs;
ofs.open("c:\temp\somefile.txt")



Will Windoze让你把标签放在文件名中?请记住

\在C ++中很特别。

Will Windoze let you put tabs in a file name? Remember
\ is special in C++.


这篇关于为什么流失败()位设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆