char * tmpnam ( char * buffer );
Generate a unique temporary filename.
A string containing a unique filename is generated.
This string can be used to create a temporary file without overwriting any existing one.
If the buffer parameter is NULL, the resulting string is stored in an internal static array that can be accessed by the return value. The content of this string is stored until a further call to this function erases it.
If the buffer parameter is not NULL, it must point to an array of at least L_tmpnam bytes that will be filled with the proposed tempname. L_tmpnam is a contant defined in stdio.h
A pointer to the string containing the proposed name for a temporary file. If NULL was specified as the buffer this points to an internal buffer that will be overwritten the next time this function is called, otherwise it returns the buffer parameter.
If an error occurs this function returns NULL.
Defined in ANSI-C.
/* tmpnam example */
char buffer [L_tmpnam];
char * pointer;
printf ("Tempname #1: %s\n",buffer);
pointer = tmpnam (NULL);
printf ("Tempname #2: %s\n",pointer);
This program will generate two different names for temporary files. Each one has been created by one of the two methods how tmpnam can be used.