Home > OS >  Converte int to char*
Converte int to char*

Time:05-22

int num = 123;
char num_charr[sizeof(char)];
std::sprintf(num_char, "%d", num);

how to convert int the same way without using sprintf? I Only Need The Code To Convert Without print.

CodePudding user response:

char num_charr[12]; // space for INT_MIN value -2147483648
itoa( num, num_charr, 10 );

Note: itoa is not supported on all compilers.

  • Related