gleason@pegasus.UUCP (Jim Gleason) (07/21/89)
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 ************************************************************/