C ++ rdstate()返回值 [英] C++ rdstate() Return Values

查看:164
本文介绍了C ++ rdstate()返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想了解C ++ rdstate()函数是如何工作的。我真的有了基本的想法,但后来我发现这段代码 https://msdn.microsoft.com/en- us / library / 04z0z51c.aspx [ ^ 让我很困惑。

有人可以解释一下返回值的含义吗? (0-0-0 4-2-1)为什么我得到不同的价值观?感谢您的帮助。

Hello all I am trying to understand how C++ rdstate() function works. I really got the basic idea but then I found this code https://msdn.microsoft.com/en-us/library/04z0z51c.aspx[^] which confused me.
Can somebody explain the meanings of the return values? (0-0-0 4-2-1) and why I am getting different values? Thanks for the help.

推荐答案

在该链接下给出的示例做了两件事:



1)它显示刚刚打开的流的错误状态标志的值。在此示例中,流打开现有文件,该文件非空。只有在这种情况下,您才会看到所有三个标志的值都为0.



2)它将所有三个错误状态标志设置为打开然后打印它们的值。由于badbit定义为值4,failbit和eofbit分别定义为值2和1,我们看到4 2 1的输出。
The example given under that links does two things:

1) It display the values of the error state flags of a stream just opened. In this example the stream opens an existing file, which is non-empty. Only in that case you will see that all three flags have the value of 0.

2) It sets all three error state flags to on and then prints their value. As the badbit is defined with value 4 and the failbit and eofbit with value 2 and 1 respectively, we see the output of 4 2 1.


这篇关于C ++ rdstate()返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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