Xref: utzoo comp.sources.games.bugs:969 comp.lang.c:20095 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!wasatch!uplherc!giga!gleason From: gleason@giga.UUCP (Jim Gleason) Newsgroups: comp.sources.games.bugs,comp.lang.c Subject: Re: vsprintf undefined Summary: a quick/dirty pseudo vsprintf routine... Keywords: vsprintf varargs Message-ID: <465@giga.UUCP> Date: 20 Jul 89 21:43:57 GMT References: <3171@puff.UUCP> Organization: Unisys, Salt Lake City, Utah Lines: 56 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 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 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =