Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900