A:
通常的方法是,在运算之前把运算对象,和头文件
同时参见问答19.39
补充链接:更多示例代码
(This Chinese translation isn't confirmed by the author, and it isn't for profits.)
Translator : jhlicc@gmai1.c0m
int
chkadd(int a, int b)
{
if(INT_MAX - b < a) {
fputs("int overflow\n", stderr);
return INT_MAX;
}
return a + b;
}
Origin : http://c-faq.com/misc/intovf.html