So I am just trying to add two numbers together,
The first one is P1 = 2147483647
and the other is P2 = 1
This should overflow the type int so I wrote this to try to prevent the computer from doing the overflow
if((P1 + P2) > sizeof(int)){
halt = 1; /*halt is just a flag*/
}
But the computer obviously still tries to do the sum to check it, giving me a runtime error before the message I wrote that simply says that I cannot add those two number together. How can I do that without occurring into the runtime error and just displaying my message?
I am also trying to do this for a subtraction and multiplication but the problem is the same.
EDIT : I need to do this for a project, I don't think I can use the library limits.h