/* ============================================================================= sprintf.c -- sprintf function Version 2 -- 1987-06-11 -- D.N. Lynx Crowe ============================================================================= */ #include "stdarg.h" extern long dofmt_(int (*putsub)(), char *format, va_list args); static char *buff; static int spsub(char c); /* ============================================================================= sprintf(str, fmt, args) -- format args into str according to fmt ============================================================================= */ long sprintf(char *str, char *fmt, ...) { register long count; va_list aptr; buff = str; va_start(aptr, fmt); count = dofmt_(spsub, fmt, aptr); va_end(aptr); *buff = '\0'; return(count); } /* ============================================================================= spsub(c) - put c into the output string ============================================================================= */ static int spsub(char c) { return((*buff++ = c) & 0xFF); }