int Strtoint (const char*pstr,int defaultval) {//NULL pointer access if (pstr==0) return defaultval;
int result=1,tem=0;
Number of digits int bitnum=0;
symbol int sign=1;
const char *PTEM=PSTR;
Detects whether the first character is-or the number if (*ptem== '-') {sign=-1;
Whether it is at the end or in the middle there is ' if ' ((*++ptem)!=0) {if (*ptem> ' 0 ' &&*ptem<= ' 9 ') {
-1 *=n result*= (*ptem-' 0 ');
Calculate the number of bits bitnum= (strlen (PSTR)-2);
} else {return defaultval;
}} else {return defaultval;
}} else if (*ptem> ' 0 ' &&*ptem<= ' 9 ') {result= (*ptem-' 0 ');
Calculate the number of bits bitnum= (strlen (PSTR)-1);
} else {return defaultval;
} ptem++; Detects that the remainder of the string has no illegal ' *ptem!=0 ' truncation while (a) {///illegal if (*ptem< ' 0 ' | | *ptem> ' 9') return defaultval;
Calculation results Tem=tem*10+n tem=tem*10+ (*ptem-' 0 ');
ptem++;
}//combination first and subsequent digits return (Tem+result*pow (10,bitnum)) *sign; }