Defined in header
char *tmpnam( char *filename );
errno_t tmpnam_s(char *filename_s, rsize_t maxsize);
filename. The function is capable of generating up to TMP_MAX of unique filenames, but some or all of them may be in use in the filesystem and thus not suitable return values.
filename_sis a null pointer
maxsizeis greater than RSIZE_MAX
maxsizeis less than the generated file name string
- As with all bounds-checked functions,
tmpnam_sis only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including
tmpnam_s modify static state (which may be shared between these functions) and are not required to be thread-safe.
|filename||-||pointer to the character array capable of holding at least L_tmpnam bytes, to be used as a result buffer. If null pointer is passed, a pointer to an internal static buffer is returned.|
|filename_s||-||pointer to the character array capable of holding at least L_tmpnam_s bytes, to be used as a result buffer.|
|maxsize||-|| maximum number of characters the function is allowed to write (typically the size of the |
filenamewas not a null pointer. Otherwise a pointer to an internal static buffer is returned. If no suitable filename can be generated, null pointer is returned.
filename_son success. On error, returns non-zero and writes the null character to
filename_sis not null and
maxsizeis not zero and is not greater than RSIZE_MAX).
Although the names generated by
tmpnam are difficult to guess, it is possible that a file with that name is created by another process between the moment
tmpnam returns and the moment this program attempts to use the returned name to create a file. The standard function tmpfile and the POSIX function mkstemp do not have this problem (creating a unique directory using only the standard C library still requires the use of
temporary file name: /tmp/fileRZHMwL temporary file name: /tmp/file420gSN
- C11 standard (ISO/IEC 9899:2011):
- 126.96.36.199 The tmpnam function (p: 303-304)
- K.188.8.131.52 The tmpnam_s function (p: 587-588)
- C99 standard (ISO/IEC 9899:1999):
- 184.108.40.206 The tmpnam function (p: 269-270)
- C89/C90 standard (ISO/IEC 9899:1990):
- 220.127.116.11 The tmpnam function
| returns a pointer to a temporary file |