Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!think!ames!amdcad!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: goto's and switch statements -- mild proposal Message-ID: <27281@sun.uucp> Date: Fri, 4-Sep-87 16:11:19 EDT Article-I.D.: sun.27281 Posted: Fri Sep 4 16:11:19 1987 Date-Received: Sat, 5-Sep-87 22:42:21 EDT References: <855@tjalk.cs.vu.nl> <2683@hoptoad.uucp> <916@haddock.ISC.COM> <732@spar.SPAR.SLB.COM> Sender: news@sun.uucp Lines: 31 > And what, pray, will be the value returned by such an integer sprintf ? > I suppose it will be the number of characters printed, or something else > equally useless. I.e., as useless as its current return value? It takes less effort to get the address of the buffer than it does to get the length of the string; the latter requires a call to "strlen" to get some information that, in many implementations of "sprintf", is already at hand. > What about all my code where I do something like: > > f = fopen(sprintf(buf, filename, seq_num++), ...); So change it to (void) sprintf(buf, filename, seq_num++); f = fopen(buf, ...); What's the problem? It may be trivially less "cute", but so what? > This seems like a gratuitous change to me ! It may seem that way, but 1) it makes the "*printf" family more uniform to have them all return the number of characters generated, 2) it causes "sprintf" to return something that takes more effort to compute independently than does the value it used to return, and 3) it's in the current ANSI C draft, so if you don't like it you'd better make a last-ditch effort to get it changed or learn to live with it. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com