Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How does C++ convert CString data into decimals?
How does C++ convert CString data into decimals?
Transfer to others:/tsingfeng/article/details/5844838

1, Atoy

Function: Converts a string to an integer.

Usage: Intatoi (constchar * nptr);

Atoi is the abbreviation of array to integer. Atoi () scans the parameter nptr string, and returns zero if the first character is not a number or symbol; Otherwise, it starts a type conversion, then stops the conversion when it detects a non-numeric or terminator /0, and returns an integer. Parameters:

*nptr: the string to be converted.

Return value:

Int: converted integer.

Note: the header file of this function is "stdlib.h"

2. Atoll

Function: Converts a string into an integer.

Usage: long atol (constchar * nptr);

Atol () will scan the parameter nptr string, skip the leading space character, start the conversion until it encounters numbers or positive and negative symbols, and then end the conversion when it encounters non-numbers or the end of the string ('/0'), and return the result.

Parameters:

*nptr: the string to be converted.

Return value:

Long: converted long integer.

Note: the header file of this function is "stdlib.h"

3、atof

Function: Converts a string to a double-precision floating-point number.

Usage: double atof (constchar * nptr);

-atof () scans the parameter nptr string, skips the leading space character, and starts conversion until it encounters a number or a sign, then ends the conversion when it encounters a non-number or the end of the string ('/0'), and returns the result. The parameter nptr string can contain symbols, decimal points or E(e) to represent the exponential part, such as 123.456 or 123e-2.

Parameters:

*nptr: the string to be converted.

Return value:

Double: converted double-precision floating-point number.

Note: the header file of this function is "stdlib.h"

4、strtod

Function: Converts a string to a double-precision floating-point value and reports all remaining digits that cannot be converted.

Usage: double strod (constchar * nptr, char * * endptr);

-strtod () scans the parameter nptr string, skips leading space characters, and does not start the conversion until it encounters numbers or positive and negative symbols, and ends the conversion until a non-number or the end of the string ('/0') appears, and returns the result. If endptr is not empty, endptr will return the character pointer in the nptr terminated due to unqualified conditions. The parameter nptr string can contain symbols, decimal points or E(e) to represent the exponential part. For example, 123.456 or 123e-2.

Parameters:

*nptr: the string to be converted.

**endptr: If endptr is not empty, endptr will return the character pointer in nptr terminated due to unqualified conditions.

Return value:

Double: converted double-precision floating-point number.

Note: the header file of this function is "stdlib.h"

5、strtol

Function: Converts a string to a long integer and reports all remaining digits that cannot be converted.

Usage: long int strtol (constchar * nptr, char * * endptr, intbase);

-This function will convert the parameter nptr string into a long integer according to the parameter cardinality. Parameter cardinality ranges from 2 to 36, that is, 0. The parameter base indicates the basic system adopted. For example, if the base value is 10, the base system is 10, and if the base value is 16, the base system is 16. When the base value is 0, it is converted to 10, but when the prefix is "0x", it is converted to 16, and when the prefix is "0" instead of "0x", it is converted to 8. First, strtol () scans the parameter nptr string, skips the leading space character, and starts the conversion until it encounters a number or a sign, then ends the conversion when it encounters a non-number or the end of the string ('/0'), and returns the result. If the parameter endptr is not empty, the character pointer in nptr terminated due to unqualified conditions will be returned by endptr.

Parameters:

*nptr: the string to be converted.

**endptr: If endptr is not empty, endptr will return the character pointer in nptr terminated due to unqualified conditions.

Cardinality: the binary system adopted.

Return value:

Long int: converted long integer.

Note: the header file of this function is "stdlib.h"

6、strtoul

Function: Converts a string to an unsigned long value and reports all remaining digits that cannot be converted.

Usage: unsigned long int strool (constchar * nptr, char * * endptr, intbase);

Strtoul () converts the parameter nptr string into an unsigned long integer based on the parameter base. Parameter cardinality ranges from 2 to 36, that is, 0. The parameter base indicates the basic system adopted. For example, if the base value is 10, the base system is 10, and if the base value is 16, the base system is 16. When the base value is 0, it is converted to 10, but when leading characters such as' 0x' are encountered, it is converted to 16. Strtoul () first scans the parameter nptr string, skips the preceding space string, and starts the conversion until it encounters numbers or positive and negative symbols, then ends the conversion when it encounters non-numbers or the end of the string (""), and returns the result. If the parameter endptr is not empty, the character pointer in nptr terminated due to unqualified conditions will be returned by endptr.

Parameters:

*nptr: the string to be converted.

**endptr: If endptr is not empty, endptr will return the character pointer in nptr terminated due to unqualified conditions.

Cardinality: the binary system adopted.

Return value:

Unsigned long integer: converted unsigned long integer.

Note: the header file of this function is "stdlib.h"