COS 126 Exercise Set 6 |
Answers |
These programming exercises are intended help review the material on recursion, pointers, and dynamic memory allocation. Do not turn in solutions.
itoa
: char *itoa(int n, int
b)
returns a dynamically allocated null-terminated string giving the
character representation of n
in base b
. The caller
must deallocate the returned string. For example:
Prints 12001 and deallocateschar *s = itoa(875, 5); printf("%s\n", s);
s
.Try to implement these programs before looking at the suggested solutions.