Listing 7(form.h)

/******************************************************************/
/*         Formatted output functions.   Note: the return value   */
/*          is only good until a form function is used again.     */
/******************************************************************/
#ifndef INCLUDE_form
#define INCLUDE_form

#ifndef_STDIO_H
   #include <stdio.h>
#endif

static char _form_s[256];


static char *dec(long i,int w=0)
      { sprintf(_form_s, "%*ld", w, i);
        return _form_s;
      }

static char *hex(int i,int w=0)
      { sprintf(_form_s, "%0*X", (w ? w : sizeof(int)), i);
        return _form_s;
      }

static char *hex(long i, int w=0)
      { sprintf(_form_s, "%0*X", (w ? w : sizeof(long)), i);
        return _form_s;
      }
static char *chr(int i,int w=0)
      { sprintf(_form_s, "%*c", w, i);
        return_form_s;
      }

static char *form(char *f,...)
      { vsprintf(_form_s, f, ...); return _form_s; }

#endif