COS 126: Fall 1996 Exercise Set 5 |
Answers |
These programming exercises are intended help review the material on recursion and character pointers. Do not turn in solutions.
int itoa(int n, int
b, char *str)
from Exercise Set 4 using only
pointers. Recall that itoa
fills str
with a
null-terminated string giving the character representation of n
in
base b
and returns the length of this string. For example:
Setschar buf[20]; k = itoa(875, 5, buf); printf("%s\n", buf);
k
to 5 and
prints 12001.itoa
using
pointers.Try to implement these programs before looking at the suggested solutions.