ios rdstate() function in C++ with Examples
The rdstate() method of ios class in C++ is used to read the internal state of this stream.
Syntax:
iostate rdstate() const;
Parameters: This method does not accept any parameter.
Return Value: This method returns the current internal state of this stream.
Example 1:
#include <bits/stdc++.h>
using namespace std;
int main()
{
stringstream ss;
cout << "stream rdstate: "
<< ss.rdstate() << endl;
return 0;
}
|
Output:
stream rdstate: 0
Example 2:
#include <bits/stdc++.h>
using namespace std;
int main()
{
stringstream ss;
ss.clear(ss.failbit);
cout << "stream rdstate: "
<< ss.rdstate() << endl;
return 0;
}
|
Output:
stream rdstate: 4
Reference: hhttp://www.cplusplus.com/reference/ios/ios/rdstate/
Last Updated :
02 Sep, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...