Advertisement
SteveStage

Untitled

Mar 4th, 2023
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. int main()
  5. {
  6.     std::ifstream f;
  7.     f.exceptions(std::ifstream::failbit);
  8.     try
  9.     {
  10.         f.open("ggg.txt", std::ios::binary);
  11.         std::cout << "i'm bad" << std::endl;
  12.     }
  13.     catch (const std::ifstream::failure& e)
  14.     {
  15.         std::cout << e.what() << std::endl;
  16.     }
  17.     std::system("pause");
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement