Click here to Skip to main content
15,891,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know how to make an error handling for this code without using any class.
-
Would that be possible?

What I have tried:

#include <stdio.h>


int main()
{


int a;
int b;
int sum;
printf("Enter first number:");
scanf("%d", &a );
printf("Enter second number:");
scanf("%d", &b );
printf("The sum of:");
printf("%d", sum=a+b);
printf("The product of:");
printf("%d", sum=a*b);
printf("The quotient of:");
printf("%d", sum=a/b);
printf("The difference of:");
printf("%d", sum=a-b);
printf("The modulus of:");
printf("%d", sum=a%b);
return(0);

}
Posted
Updated 12-Jun-20 19:45pm
v2

To add to what Dave has said, not only does C not have generic error catching, it doesn't have any concept of classes either.

C is an old language, and these kind of things were added to languages which either were a superset of C like C++, or were inspired by C (but not compatible) like C#.
 
Share this answer
 
There's no such thing in C. There is no structured error handling, like try/catch blocks in C#.

Google for "C error handling" for strategies on how to do it in C.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900