tempnam() - temporary file routine
#include <stdio.h>
char * tempnam (const char *dir, char *pfx)
The tempnam(3) function is similar to tmpnam(3) in that it returns a pointer to a pathname of a file that does not exist at the time of the call. Unlike tmpnam(3), you can specify the directory that will contain the file (dir) if there is no defined temporary directory, and you can specify the filename's prefix, (pfx).
The tempnam(3) function also looks to use different directories by default than does tmpnam(3). It determines the directory for the file using the following steps:
The argument pfx, if non-NULL, is used to specify a file name prefix, which will be the first part of the created file name. The pfx can be up to five characters long.
Tempnam(3) allocates space for the string; the pointer can be used in a call to free(3).
The tempnam(3) function returns a pointer to a file name on success, and a NULL pointer on error.
The tempnam(3) function may fail and set the global variable errno for this reason:
Using tempnam(3) is discouraged for these reasons:
mktemp(3)
tmpfile(3)