Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C++ int is converted to string type.
C++ int is converted to string type.
You can assign a string directly after itoa is completed.

Itoa is a C function, which can convert int type into C type string, and the conversion from C type string to C++ can be directly assigned. If VS20 10 will warn the security of the itoa function, use:

_itoa_s()

Four parameters, the first parameter is the int to be converted, the second parameter is the string pointer to be converted, the third parameter is the length of the digits of the int (remember to add one, and _ itoa _ s should add' \ 0' at the end), and the fourth parameter is how many decimal digits to be converted.

Extended data:

Itoa function

Function: Converts an integer numeric variable to a character array variable. Located in < cstdlib > Atoy, it has the opposite function.

Usage: char * itoa (int value, char * str, int base);

Return value: Returns a pointer to str without error.

Int value is a converted integer, an array of characters stored after char *string conversion, and a number converted by int radix, such as 2,8, 10, 16, etc. , the size should be between 2 and 36.

Baidu encyclopedia -itoa