how tmpname works

The Beardless Wonder rmj at tcom.stc.co.uk
Wed Oct 3 00:57:12 AEST 1990


In article <7372 at darkstar.ucsc.edu> aryeh at cash.uucp (the over worked C something or another) writes:
>From tmpname(3) or sunos4.1:
>>     char *tmpnam (s)
>>     char *s;
>>     [Rest of manual page]
>
>I am to assume if I call tmpname once with a NULL arg and then call it
>again with a pointer to char s[...] that it will nuke the old L_tmpnam?

No, but it will nuke the name string that the first call to tmpname
produced (unless you have strcopied it somewhere safe first). L_tmpnam
is the constant defining the minimum length that your char s[] should
be. Thus an array declared as

   char s[L_tmpnam];

would be big enough to safely use as an argument to tmpname. As a
constant, L_tmpname is not subject to nuking (well, you know what I
mean).
-- 
* Windsinger                 * "But soft, what light through yonder
* rmj at islay.tcom.stc.co.uk   *      airlock breaks?"
* rmj at tcom.stc.co.uk         *    --RETURN TO THE FORBIDDEN PLANET
* rmj10 at phx.cam.ac.uk        *  You've gotta be cruel to be Khund!



More information about the Comp.lang.c mailing list