#include <iostream> using namespace std; const int maxv = (1 << 31) - 1; const int minv = (1 << 31) ; int strToInt(const char *str) { if(!str) exit(-1); char *p = const_cast<char*>(str); int re = 0; bool nagetive = false; if(*p == '-' || '+') { if(*p == '-') nagetive = true; p++; } while(*p) { re *= 10; re += (*p++ - '0'); } return nagetive ? (0 - re) : re; } int main(void) { // cout << maxv << endl << minv << endl; char a[] = "-123456"; cout << strToInt(a) << endl; return 0; }