🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.d
Article #161

Re: vsprintf undefined

#161
From: Jim Gleason
Date: Thu, 20 Jul 1989 21:04
50 lines
2118 bytes
In article <3171@puff.UUCP>, kschnitz@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 quick and dirty little programming trick...

Just beware that this has a fixed & limited parameter capability
i.e.  floats take 2 args[], chars & ints take 1 args[].
If more capability is needed, just continue adding args[].

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

/*VARARGS2 PRINTFLIKE2*/
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 ************************************************************/
Technical Details
Message-ID: <464@pegasus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!wasatch!uplherc!pegasus!gleason
References: <3171@puff.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!wasatch!uplherc!pegasus!gleason
From: gleason@pegasus.UUCP (Jim Gleason)
Newsgroups: comp.sources.d,comp.lang.c
Subject: Re: vsprintf undefined
Summary: a quick/dirty routine to substitute for vsprintf
Keywords: pseudo vsprintf
Message-ID: <464@pegasus.UUCP>
Date: 20 Jul 89 21:04:37 GMT
References: <3171@puff.UUCP>
Organization: Unisys, Salt Lake City, Utah
Lines: 50