devxlogo

Porting itoa Windows STL Code to Linux

Porting itoa Windows STL Code to Linux

There is no default itoa implementation in the STL under Linux. If you include , it won’t work. If you disable the STL from the GCC command line, you lose the STL and your code will not be portable. This tip can help you port your code from Windows to Linux in such a situation.

#if defined(__linux__)#define _itoa   itoachar* itoa(int value, char*  str, int radix){    int  rem = 0;    int  pos = 0;    char ch  = '!' ;    do    {        rem    = value % radix ;        value /= radix;        if ( 16 == radix )        {            if( rem >= 10 && rem 

devx-admin

Share the Post: