Thursday, March 24, 2011

atoi bug free C cod. My atoi.

int atoi( char* pStr )
{
int iRetVal = 0;

if ( pStr )
{
while ( *pStr && *pStr <= '9' && *pStr >= '0' )
{
iRetVal = (iRetVal * 10) + (*pStr - '0');
pStr++;
}
}
return iRetVal;
}

No comments:

Post a Comment