User Tools

Site Tools


c_-_c_exception_handling:exceptions

C - C++ Exception Handling - Exceptions

#include <iostream>
using namespace std;
 
int main()
{
  cout << "Start\n";
 
  try {
    cout << "Inside try block\n";
    throw 1;                          // throw an error
    cout << "This will not execute";
  }
  catch (int i) {                     // catch an error
    cout << "Caught an exception -- value is: ";
    cout << i << "\n";
  }
  cout << "End";
  return 0;
}
c_-_c_exception_handling/exceptions.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki