Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C++ data type conversion problem: how to convert the char * argv [] data entered in the main function into a 64-bit unsigned long integer?
C++ data type conversion problem: how to convert the char * argv [] data entered in the main function into a 64-bit unsigned long integer?
Yes, as mentioned upstairs.

In addition, I will give you a modified source code, which is equivalent to _atoi64, and the number returned is long long, which can support the processing of numbers greater than 4294967295.

long long MY_atol( const char *nptr)

{

int c; /* Current character */

Long long zong; /* Current Total */

Int symbol; /* If'-',it is negative, otherwise it is positive */

/* Skip blank space */

while(is space((int)(unsigned char)* nptr))

++ nptr;

c =(int)(unsigned char)* nptr++;

Symbol = c;; /* Save the flag instruction */

if (c == '-' || c == '+')

c =(int)(unsigned char)* nptr++; /* Skip symbol */

Total = 0;

while (isdigit(c)) {

Total = 10 * total+(c-'0'); /* Cumulative number */

c =(int)(unsigned char)* nptr++; /* Get the next character */

}

If (symbol = ='-')

Return-Total;

other

Returns the total; /* Returns the result and negates it if necessary */

}