vsprintf undefined

Jim Gleason gleason at giga.UUCP
Fri Jul 21 07:43:57 AEST 1989


In article <3171 at puff.UUCP>, 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.
> 
> Kevin Schnitzius     (Encore Computer Corporation, Ft. Lauderdale, Florida)

Try this little programming trick...
Note: The format string uses one args[], floats use 2 args[], ints use 1 args[]
      and so forth and so on.
If you need more parameter capabilities than this offers, just add more args[].

 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

/********************************************************/
/* Pseudo vsprintf ----- Limited parameter capabilities */
/********************************************************/

/*VARARGS1 PRINTFLIKE1*/
int Vsprintf (str, argv)

    char *str;
    char *argv;

{ /* Begin Vsprintf **********************************************************/

    /********** Local Declaration Section **********/

    char **args;
    int nchars;

    /********** Code Section **********/

    args = (char **) &argv;
    nchars = sprintf(str,
		     args[ 0],args[ 1],args[ 2],args[ 3],args[ 4],
		     args[ 5],args[ 6],args[ 7],args[ 8],args[ 9],
		     args[10],args[11],args[12],args[13],args[14],
		     args[15],args[16],args[17],args[18],args[19]);
#ifdef BSD4
    /* Berkeley's sprintf does not return string length: */
    nchars = strlen(str);
#endif

    return(nchars);

} /* End Vsprintf ************************************************************/

 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

 :-) Jimbo

 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =



More information about the Comp.lang.c mailing list