The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


mktemp - make a unique filename


#include <stdlib.h>

char *mktemp(char *template);


The mktemp() function replaces the contents of the string pointed to by template by a unique filename and returns template. The application must initialise template to be a filename with six trailing 'X's; mktemp() replaces each 'X' with a single byte character from the portable filename character set.


The mktemp() function returns the pointer template. If a unique name cannot be created, template points to a null string.


No errors are defined.




Between the time a pathname is created and the file opened, it is possible for some other process to create a file with the same name. The mkstemp() function avoids this problem.

For portability with previous versions of this document, tmpnam() is preferred over this function.




mkstemp(), tmpfile(), tmpnam(), <stdlib.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]