Ios bad() function in C++In this article, we will discuss the std::ios::bad() function in C++ with its syntax and examples. The std::ios class is the root class for every single standard input/output stream in C++. It provides numerous flags that indicate the current state of the stream, one of which is called std::ios::badbit. The badbit flag signifies a critical streaming error, denoting that an unchangeable error happened during an I/O operation. The bad() member method of the std::ios class may be used to determine whether the badbit for a given stream is set. The following is how it works:
Syntax:It has the following syntax: Parameters: No parameters are accepted by this procedure. Return Value: If the data stream has a badbit set, this technique returns true; otherwise, it returns false. Complexity Analysis:Time Complexity: O(1) Space Complexity: O(1) Example 1: Badfun1.cppOutput: Is the stream bad: 0 Example 2: BadFun2.cpp Output: is the stream bad: 1 Next TopicIterator Invalidation in C++ |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India