home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 316 / libsrc / sprintf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  716 b   |  46 lines

  1. /*
  2. print_hex(x)
  3. int x;
  4. {
  5.   char * foo = "0123456789ABCDEF";
  6.   int i;
  7.   char buf[10];
  8.  
  9.   for (i = 7 ; i >= 0 ; i--)
  10.     buf[7 - i] = foo[((x >> (i << 2)) & 0x0F)];
  11.   buf[8] = ' ';
  12.   buf[9] = '\0';
  13.   dbgstr(buf);
  14. }
  15. */
  16. void __sprintf_pushc(c, str_p)
  17. char c;
  18. char ** str_p;
  19. {
  20.   char * str = * str_p;
  21. /*
  22.   dbgstr("  enter pushc ");
  23.   print_hex(c);
  24.   print_hex(str_p);
  25.   print_hex(*str_p);
  26.   dbgstr("\r\n");
  27. */
  28.   *str++ = c;
  29.   *str_p = str;
  30. }
  31.  
  32. void sprintf(target, template, args)
  33. char * target;
  34. char * template;
  35. long args;
  36. {
  37. /*
  38.   dbgstr(" enter sprintf\r\n");
  39. */
  40.   _printf_guts(template, &args, __sprintf_pushc, &target);
  41.   *target = '\0';
  42. /*
  43.   dbgstr(" exit sprintf\r\n");
  44. */
  45. }
  46.