Home > Back-end >  [help!] The inside of the GPS module code
[help!] The inside of the GPS module code

Time:09-21

//====================================================================//
//syntax format: static int Str_To_Int (char * buf)
//implementation function: to split a string into an integer
//and count: the string
//return value: back into the integral value
//====================================================================//
Static int Str_To_Int (char * buf)
{
Int rev=0;
Int dat.
Char * STR=buf;
While (* STR!='\ 0')
{
The switch (* STR)
{
Case '0' :
Dat=0;
break;
Case '1' :
Dat=1;
break;
Case '2' :
Dat=2;
break;
Case '3' :
Dat=3;
break;
Case '4' :
Dat=4;
break;
Case '5' :
Dat=5;
break;
Case '6' :
Dat=6;
break;
Case '7' :
Dat=7.
break;
Case '8' :
Dat=8;
break;
Case '9' :
Dat=9;
break;
}

Rev=rev * 10 + dat;
STR + +;
}

Return rev;
}


Could you tell me the to convert a string into an integer what this function is used for?

CodePudding user response:

The text for converting a literal integer types of computer storage, translate the memory is just like the "255" 0 XFF, but a little poor robustness, input text with non-numeric characters die too ugly ~
  • Related