If you need interoperability, the man page for tmpnam offers:
tmpnam manual page
BUGS
Never use this function. Use mkstemp(3) instead.
mkstemp man page
SYNOPSIS
#include <stdlib.h>
int mkstemp(char *template);
DESCRIPTION
The mkstemp() function generates a unique temporary file name from template. The last six characters of template must be
XXXXXX and these are replaced with a string that makes the filename unique. The file is then created with mode read/write
but all this suggests that you prepared your template with the prefix of the contents of the TMP environment variable.
source
share