Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SP0302demo.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- LONG filter1(DWORD ex);
- int count=0;
- const int max_count=3;
- int _tmain(int argc, _TCHAR* argv[])
- {
- FILE *fin;
- errno_t err;
- int a=0,b=0,y=0;
- err=fopen_s(&fin,"D:\\A.TXT","rt");
- fscanf_s(fin,"%d\n",&a);
- printf_s("a=%d",a);
- fscanf_s(fin,"%d\n",&b);
- printf_s("b=%d",b);
- __try {
- y=a/(a+b);
- }
- __except(filter1(GetExceptionCode()))
- {
- b=-b;
- y=(a+b)/a;
- }
- printf_s("y=%d\n",y);
- getchar();
- return 0;
- }
- LONG filter1(DWORD ex)
- {
- if (ex== EXCEPTION_INT_DIVIDE_BY_ZERO)
- if (++count>max_count)
- return EXCEPTION_EXECUTE_HANDLER;
- else
- printf("\n******** %d ********\n",count);
- return EXCEPTION_CONTINUE_EXECUTION;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement