The tempnam function generates filenames for temporary files. It
allows you to control the choice of a directory.
If the directory argument is null or points to a string that is
not a pathname for an appropriate directory, the pathname defined
as P_tmpdir in the <stdio.h> header file is used. For programs
running under a detached process, the directory argument cannot
be null.
You can bypass the selection of a pathname by providing the
TMPDIR environment variable in the user environment. The value
of the TMPDIR variable is a pathname for the desired temporary
file directory.
Use the prefix argument to specify a prefix of up to five
characters for the temporary filename.
The tempnam function returns a pointer to the generated pathname,
suitable for use in a subsequent call to the free function.
See also free.
NOTE
In contrast to tmpnam, tempnam does not have to generate
a different filename on each call. tempnam generates a new
filename only if the file with the specified name exists. If
you need a unique filename on each call, use tmpnam instead
of tempnam.