|
From: Per W. <pw...@ia...> - 2004-11-07 12:20:42
|
Trivial exercise. You have a static buffer large enough never to overflow for the numeric range you receive as input. You fill in the buffer from the end by taking your number modulo 10 to find one digit. Then number divided by time to shrink the number. Continue until number is zero. Observe to take special care if number was zero from the beginning. Also take care about negative numbers. Easiest is to set a flag that is was negative and then negate it and perform above algorithm. In end, check flag and if needed add a '-' to the buffer. Return the pointer to the first used character in the buffer. /Per W On Sat, 6 Nov 2004, Rob Lawless wrote: > I viewed the last previous thread about a strtoi function in whihc i understand fully > but now i would look to know how to implment a itostr function i.e conver an integer to a string > can someone please lead me in the right direction > regards > Rob |