[an error occurred while processing this directive]
|
//
// ** itoa -- the function converts an integer to ASCII string.
// Returns a pointer to the string.
//
char *itoa(int _value, char *buffer)
{
char _pos = 1;buffer[0] = (_value<0)? '-' : ' ';
if (_value < 0)
_value = -_value;
if (_value > 9) ++_pos; // Check the number of digits
if (_value > 99) ++_pos; //
if (_value > 999) ++_pos; //
if (_value > 9999) ++_pos; //
buffer[_pos+1] = 0; // Terminate output string with NULL
// while (_value >= 10)
do { // the conversion
buffer[_pos--] = (_value%10) + '0';
_value /= 10;
}
while (_value != 0);
return buffer;
}
E-mail: info@telesys.ru