Josh Parker <ecu.edu> wrote:
Drop the '*' in front of hexstring, or you get an array of 10
uninitialized char pointers instead of an array with enough space
for 9 characters.
Otherwise that looks completely reasonable, at least as long as you're
on a typical 32-bit machine. To make sure it works with whatever size
an integer has on a machine you could use instead
char hexstring[ ( CHAR_BIT * sizeof( int ) ) / 4 + 2 ];
CHAR_BIT is the number of bits in the smallest unit on your machine
(a char per definitionem), which is typically 8, but could be any
other larger value in principle (don't forget to include <climits>
or <limits.h> when you're using it). The additional 2 is one for
the '\0' at the end of the string and another one for cases where
CHAR_BIT can't be divided by 4.
\ Jens Thoms Toerring ___ fu-berlin.de