Name

tmpnam function — Returns a temporary filename

Synopsis

char* tmpnam(char* s)

The tmpnam function generates a unique filename and returns a pointer to that name. If the s parameter is not null, it must point to an array of at least L_tmpnam characters, the new filename is copied into that array, and s is returned. If s is null, a static character array is returned; the contents of the array are overwritten each time tmpnam is called.

Warning

The tmpnam function has a race condition: after it generates a “unique” filename, but before the file is actually created, another program might generate the same “unique” filename. Use tmpfile instead of tmpnam to ensure that the file is created, thereby ensuring that its name is unique.

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.