How to use error handler????

float num;
char buffer[20];
printf("ENTER A POSITIVE NUMBER:");
gets(buffer);
num=atoi(buffer);
if(num<=0&&buffer[0]!='0');
{printf("Not a positive number.\n");
printf("Hit any key to exit...");
getch();
exit(0);
}printf("num==%f\n",num);

HOW DOES THIS CODE HANDLE ERRORS??
WHAT ERRORS ARE DETECTED????
I don't mean to be rude, but what exactly are you asking?

If the input is greater than zero AND not equal to zero then it outputs
1
2
Not a positive number.
Hit any key to exit...

quits with an exit status of zero.
otherwise it prints the number.

HTH
Topic archived. No new replies allowed.