Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/5/84; site baylor.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!ut-sally!ut-ngp!shell!neuro1!baylor!peter
From: peter@baylor.UUCP (Peter da Silva)
Newsgroups: net.lang.c
Subject: Re: Re: Re: Re:  casts to (void)
Message-ID: <419@baylor.UUCP>
Date: Fri, 16-Aug-85 13:53:04 EDT
Article-I.D.: baylor.419
Posted: Fri Aug 16 13:53:04 1985
Date-Received: Tue, 20-Aug-85 21:30:36 EDT
References: <441@brl-tgr.ARPA> <261@kitty.UUCP> <549@brl-tgr.ARPA> <363@baylor.UUCP> <1210@umcp-cs.UUCP>
Organization: The Power Elite, Houston, TX
Lines: 25

> >. . . and tempnam is just a throwback to the days before sprintf.
> 
> Not really; tempnam (or mktemp) is not the same as doing
> 
> 	sprintf(fname, "/tmp/x%d", getpid());
> 
> (or variations thereupon) as it actually makes sure that such a
> file doesn't already exist (what happens when you get the same pid
> as someone else did earlier?).

Never occured to me that you could get this, but of course you can. well,
you just do this:

	for(c='a'; c<='z'; c++) {
		sprintf(fname, "/tmp/x%s%c", getpid(), c);
		if(access(fname, 7))
			break;
	}
	if(c>'z') panic

which is, of course, basically what mktemp must do. Never mind.
-- 
	Peter da Silva (the mad Australian werewolf)
		UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
		MCI: PDASILVA; CIS: 70216,1076