Namespaces
Variants

std::basic_ios<CharT,Traits>::operator!

From cppreference.com
 
 
Input/output library
I/O manipulators
Print functions (C++23)
C-style I/O
Buffers
(deprecated in C++98)(removed in C++26)
Streams
Abstractions
File I/O
String I/O
Array I/O
(deprecated in C++98)(removed in C++26)
(deprecated in C++98)(removed in C++26)
(deprecated in C++98)(removed in C++26)
Synchronized Output
Types
Error category interface
(C++11)
 
 
bool operator!() const;

Returns true if an error has occurred on the associated stream. Specifically, returns true if badbit or failbit is set in rdstate().

Parameters

(none)

Return value

true if an error has occurred, false otherwise.

Example

#include <cstdlib>
#include <fstream>
#include <iostream>

int main()
{
    std::ifstream file("test.txt");
    if