home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / gnu / mntlib16.lzh / MNTLIB16 / SPRINTF.C < prev    next >
C/C++ Source or Header  |  1993-07-29  |  836b  |  40 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <limits.h>
  4. #include "lib.h"
  5.  
  6. #if __STDC__
  7. int sprintf(char *buf, const char *fmt, ...)
  8. #else
  9. int sprintf(buf, fmt) char *buf; const char *fmt;
  10. #endif
  11. {
  12.     va_list args;
  13.     register int n;
  14.     FILE sf = 
  15.     {0L, (unsigned char *)buf, (unsigned char *)buf,
  16.          _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX,'\0'};
  17.  
  18.     va_start(args, fmt);    
  19.     n = _doprnt(&sf, fmt, args);
  20.     *(sf._ptr) = '\0';        /* always tie off the string */
  21.     va_end(args);
  22.     return(n);
  23. }
  24.  
  25. int
  26. vsprintf(buf, fmt, args)
  27.     char *buf;
  28.     const char *fmt;
  29.     va_list args;
  30. {
  31.     register int n;
  32.     FILE sf = 
  33.     {0L, (unsigned char *)buf, (unsigned char *)buf,
  34.          _IOWRT|_IOBIN|_IOSTRING|_IOFBF, 0, LONG_MAX,'\0'};
  35.  
  36.     n = _doprnt(&sf, fmt, args);
  37.     *(sf._ptr) = '\0';        /* always tie of the string */
  38.     return(n);
  39. }
  40.