Loading...

Friday, 10 August 2012

Function String to Unsigned long long int (C/C++ code))

typedef unsigned long long      u64;
typedef unsigned char              u8;

bool String_to_Long_Int (u8 *str, int len, u64 *pNumber)
{
    u64 number = 0;
    if(len <= 0)
        return FALSE;
    while(len--)
    {
        u8 ch = *str++;
        if( (ch < '0') || (ch > '9') )
            return false;
        number = (number*10+(ch-'0'));
    }
    *pNumber= number;
    return true;
}

No comments:

Post a Comment