Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C++ Programming Code Examples

Learn C++ Language

IOS Library rdstate() Function in C++ Programming Language

IOS Library rdstate() Function in C++
Get error state flags. Returns the current internal error state flags of the stream. The internal error state flags are automatically set by calls to input/output functions on the stream to signal certain errors. It is used to check get error state flags. The internal error state flags are automatically set by calls to input/output functions on the stream to signal certain errors.
Syntax for rdstate() Function in C++
#include <fstream> iostate rdstate() const;
This function does not accept any parameter. Function returns an object of type ios_base::iostate that can contain any combination of the following state flag member constants: iostate value indicates functions to check state flags (member constant) good() eof() fail() bad() rdstate() goodbit No errors (zero value iostate) true false false false goodbit eofbit End-of-File reached on input operation false true false false eofbit failbit Logical error on i/o operation false false true false failbit badbit Read/writing error on i/o operation false false true true badbit eofbit, failbit and badbit are member constants with implementation-defined values that can be combined (as if with the bitwise OR operator). goodbit is zero, indicating that none of the other bits is set. Function returns current stream error state. It is a bitmask type and can be a combination of the following constants: goodbit: no error. badbit: irrecoverable stream error. failbit: input/output operation failed (formatting or extraction error). eofbit: associated input sequence has reached end-of-file.
Data races
Accesses the stream object. Concurrent access to the same stream object may cause data races.
Exception safety
Strong guarantee: if an exception is thrown, there are no changes in the stream.
/* read the internal state of this stream by rdstate() function code example */ // C++ code to demonstrate the working of rdstate() function #include <bits/stdc++.h> using namespace std; int main() { // Stream stringstream ss; ss.clear(ss.failbit); // Using rdstate() function cout << "stream rdstate: " << ss.rdstate() << endl; return 0; }










2 const variables row & col are used to define size. If we do not make both const then error found because without "const reserve word" they are behaving as variable. Before placing