Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!decvax!tektronix!hplabs!hao!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: gripe: variable arg lists Message-ID: <1237@umcp-cs.UUCP> Date: Mon, 19-Nov-84 18:54:02 EST Article-I.D.: umcp-cs.1237 Posted: Mon Nov 19 18:54:02 1984 Date-Received: Wed, 21-Nov-84 05:11:35 EST References: <348@gitpyr.UUCP> <3106@alice.UUCP> <4648@utzoo.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 22 > > As to why _doprnt() was used: that's pretty easy. There is no standard > > analog to printf which accepts a variable argument list *as an argument*. > There is, however, a portable mechanism to do this job: sprintf followed > by passing the resulting string to whoever wants it. But this only works for (a large number of) specific cases. Suppose a string could be arbitrarily long? Then you need an arbitrarily long buffer. A function-based printf would seem to be the ``best'' way to be everything to everyone, but there is no such beast. Sigh. Granted, one should use sprintf when possible. But (as many have found out) sprintf is dangerous, since it will merrily overflow buffers and scribble on top of useful data. snprintf() and sxprintf() help, but only those who have implemented Patrick Powell's changes have those. Again, sigh. -- (This line accidently left nonblank.) In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690 UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland