can anyone teach how to use this try and catch function ???
Printable View
can anyone teach how to use this try and catch function ???
thanks
but i dunno wat is the webby trying to say
a) Instead of saying "webby", please say "web site".
b) Does "mi" mean "me"?
c) Did you start out learning Dos stuff (the basics), or did you go straight for MFC?
d) If not, try buying "Sam's Teach Yourself C++ in 21 Days" (it's a book)
e) Try researching some stuff yourself from that book
f) Try researching the rest of the stuff on your own from the internet. A lot of this stuff you could have figured out on your own.
g) If that doesn't work, try taking lessons.
h) If none of this works, THEN go for the C board.
i) If you have trouble understanding replies on the C board, find out how old you are. If you are under 11 years old, then you should probably wait until you are that old before learning C++.
Ditto on the language.
It just limits your chance of a response.
Code:__try
{
//what ever you want to catch exceptions on
}
__except(1)//EXCEPTION_EXECUTE_HANDLER known exception so use this code to handle it
{
sprintf(sBuffer,"App has caused exception %08X. app may need to be restarted.",_exception_code());
MessageBox(hWnd,sBuffer,"App Error",MB_ICONERROR);
}
Code:int x = 10, y = -20;
try
{
x = ~x++;
y = ~y
if( x != -10 )
throw( "Failed to switch X" );
if( y != 20 )
throw( "Failed to switch Y" );
cout << "X = " << x << endl;
cout << "Y = " << y << endl;
}
catch( const char *msg )
{
MessageBox(NULL, msg, "Exception", NULL);
}