Creates a unique temporary filename.
Include
<stdio.h>
Prototype
char *tmpnam(char *s);
Argument
s |
pointer to the temporary name |
Return Value
Returns a pointer to the filename generated and stores the filename in
s
. If it can not generate a filename, the NULL
pointer is
returned.
Remarks
The created filename will not conflict with an existing file name. Use
L_tmpnam
to define the size of array the argument of
tmpnam
points to.
Example
#include <stdio.h> /* for tmpnam, L_tmpnam, */
/* printf, NULL */
int main(void)
{
char *myfilename;
char mybuf[L_tmpnam];
char *myptr = (char *) &mybuf;
if ((myfilename = tmpnam(myptr)) == NULL)
printf("Cannot create temporary file name");
else
printf("Temporary file %s was created",
myfilename);
}
Example Output
Temporary file ctm00001.tmp was created