COHERENT manpages

This page displays the COHERENT manpage for tempnam() [Generate a unique name for a temporary file].

List of available manpages
Index


tempnam() -- General Function (libc)

Generate a unique name for a temporary file
#include <stdio.h>
char *tempnam(directory, name);
char *directory, *name;

tempnam() constructs  a unique temporary  name that can  be used to  name a
file.  directory points to the name  of the directory in which you want the
temporary  file written.   If this  variable is  NULL, tempnam()  reads the
environmental  variable  TMPDIR  and  uses  it  for directory.  If  neither
directory nor TMPDIR is given, tempnam() uses /tmp.

name points to  the string of letters that will  prefix the temporary name.
This string  should not be more  than three or four  characters, to prevent
truncation  or  duplication of  temporary  file names.   If  name is  NULL,
tempnam() sets it to t.

tempnam() uses malloc() to allocate a buffer for the temporary file name it
returns.  If all  goes well, it returns a pointer  to the temporary name it
has written.  Otherwise,  it returns NULL if the allocation  fails or if it
cannot build a temporary file name successfully.

See Also

libc,
mktemp(),
TMPDIR,
tmpfile(),
tmpnam()