Syntax
#include <stdio.h> char *tempnam(char *dir, char *prefix);Description
tempnam creates a temporary file name in another directory. The prefix is the prefix to the file name. tempnam tests for the existence of the file with the given name in the following directories, listed in order of precedence:
Note:
tempnam returns a pointer to the temporary name, if successful. If the name cannot be created or it already exists, tempnam returns the value NULL.
This example creates a temporary file name using the directory a:\tmp:
#include <stdio.h>#include <stdlib.h> int main(void) { char *name1; if ((name1 = tempnam("d:\\tmp", "stq")) != NULL) printf("%s is safe to use as a temporary file.\n", name1); else { printf("Cannot create unique filename\n"); return EXIT_FAILURE; } return 0; /**************************************************************************** The output should be similar to: D:\tmp\stqU3CP2.C2T is safe to use as a temporary file. ****************************************************************************/ }Related Information