Monday, July 28, 2008

C Source code for converting from Integer to String - itoa implementation.

void IntToStr( int num) {

bool bNegative =false;
if( num < 0)
bNegative =true;
char * str = new char[11];
int i =0;
while( num != 0) {

str[i++] = num % 10 + '0';
num /=10;
}
i--; int j =0;
while( j
char ch = str[j];
str[j] = str[i];
str[i] = ch;
j++; i--;
}

}

No comments:

Your Title