Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to assign an integer variable to a character array in VC++ and output its integer data?
How to assign an integer variable to a character array in VC++ and output its integer data?
C function

Atoi, converting a string into an integer variable.

Itoa, converting integer variables into characters.

For example:

# include & ltiostream & gt

int main()

{

char ch buf[5];

int k;

k = 10;

itoa(k,chBuf, 10);

Printf ("The value stored in the string is: %s\n", chbuf);

k = atoi(ch buf);

Printf ("Put the string into the value of int variable k: %d \n", k);

Returns 0;

}