#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main()
{
static char digits[] = "0123456789abcdef";
char buf[(sizeof(unsigned long) << 3) + 1];
char *ptr, *end;
int base;
unsigned long value;
base = 16;
value = -LONG_MAX -1;
end = ptr = buf + sizeof(buf) - 1;
*ptr = '\0';
printf("Start with: %ld and size of buffer is %d \(size of usi long is %d\) \n",value, (sizeof(unsigned long) << 3) + 1,sizeof(unsigned long));
do {
*--ptr = digits[value % base];
value /= base;
printf("Processing: %ld and ptr is %s\n",value,ptr);
} while (ptr > buf && value);
puts(ptr);
return 0;
}