【 以下文字转载自 JobHunting 讨论区 】
发信人: gandjmitbbs (Nothing), 信区: JobHunting
标 题: 经典题atoi的溢出处理
发信站: BBS 未名空间站 (Tue Feb 22 21:40:03 2011, 美东)
int atoi(const char* s);
assuming INT_MAX = 2^31-1, INT_MIN = -2^31, the following must hold:
atoi("2147483648") = 2147483647
atoi("-2147483649") = -2147483648
but this seems a little tricky. any elegant solution to handle the
overflow?