Mega Code Archive

 
Categories / Visual C++ .NET / Statement
 

Catch an Exception with a trycatch Block

#include "stdafx.h" #using <mscorlib.dll> using namespace System; void MyFunction() {     int x,y,z;     x = Int32::Parse(Console::ReadLine());     y = Int32::Parse(Console::ReadLine());     z = x/y;     Console::WriteLine(z); } int main(void) {     try {         MyFunction();     }     catch (...) {         Console::WriteLine(             "Exception. Unable to complete the operation.");     }     return 0; }