[comp.lang.c] sprintf value

jv@mhres.mh.nl (Johan Vromans) (09/06/87)

>>What about all my code where I do something like:
>>
>>	f = fopen(sprintf(buf, filename, seq_num++), ...);
>
>It has to become
>
>	(void) sprintf(buf, filename, seq_num++);
>	f = fopen(buf, ...);
>
>>This seems like a gratuitous change to me !
>

How about using the alternation operator (,) :

	f = fopen (((void) sprintf(buf, filename, seq_num++), buf), ...);

For clarity, I would use a define like

#define NEXTNAME(name,seq)	((void) sprintf(buf, name, seq++), buf)

--
I have lots of programs which use statements like

	used += sprintf (buf+used, ....)

One of us has to make changes....
--
-- 
Johan Vromans                              | jv@mh.nl via European backbone
Multihouse N.V., Gouda, the Netherlands    | uucp: ..{?????!}mcvax!mh.nl!jv
"It is better to light a candle than to curse the darkness"