Syntax
#include <stdio.h> char *tmpnam(char *string);Description
tmpnam produces a valid file name that is not the same as the name of any existing file. It stores this name in string. If string is NULL, tmpnam leaves the result in an internal static buffer. Any subsequent calls destroy this value. If string is not NULL, it must point to an array of at least L_tmpnam bytes. The value of L_tmpnam is defined in <stdio.h>.
tmpnam produces a different name each time it is called within a module up to at least TMP_MAX (a value of at least 25) names. Note that files created using names returned by tmpnam are not automatically discarded at the end of the program. Files can be removed by the remove function.
tmpnam returns a pointer to the name. If it cannot create a unique name; it returns NULL.
This example calls tmpnam to produce a valid file name.
#include <stdio.h> int main(void) { char *name1; if ((name1 = tmpnam(NULL)) != NULL) printf("%s can be used as a file name.\n", name1); else printf("Cannot create a unique file name\n"); return 0; /**************************************************************************** The output should be similar to: d:\tmp\acc00000.CTN can be used as a file name. ****************************************************************************/ }Related Information