vsprintf undefined

Martin Maclaren ccsmm at gdt.bath.ac.uk
Thu Jul 13 05:02:05 AEST 1989


kschnitz at puff.UUCP (Soccer Stud) writes:


>Help!  This function came with the tetris game I got for Unix based
>machines.  The problem is vsprintf is undefined using my C libraries.

>Does anyone have a simple solution?  Please post the answer because
>others have had the same problem.  Thanks in advance.

> ...

>/*VARARGS*/
>char *form (va_alist)
>  va_dcl
>{
>  va_list pvar;
>  char *fmt_string;
>  static char result[LINELEN];
>  
>  va_start (pvar);
>  fmt_string = va_arg (pvar, char*);
>  (void) vsprintf (result, fmt_string, pvar);
>  va_end (pvar);
>  return (result);
>}

How about the following....

/*VARARGS*/
char *form (va_alist)
  va_dcl
{
  va_list pvar;
  char *fmt_string;
  static char result[LINELEN];
  FILE b;
  
  va_start (pvar);
  fmt_string = va_arg (pvar, char*);

 /*  (void) vsprintf (result, fmt_string, pvar);  */

  b._flag = _IOWRT|_IOSTRG;
  b._ptr = result;
  b._cnt = LINELEN;
  _doprnt(fmt_string, pvar, &b);
  putc('\0', &b);

  va_end (pvar);
  return (result);
}


Works fine for me.

Martin.



More information about the Comp.lang.c mailing list