Inclusion In
C, this is included by (or in
C++, if is not available) per IEEE Std 1003.1, 2004, otherwise it is included through in legacy systems. In C++, it can be replaced with std::tmpnam() or std::filesystem::temp_directory_path().
Signature int mkstemp(char* template); Do note that template is a keyword in C++, for
templates. • The parameter template must be a modifiable, null-terminated character array. • The contents of template must be in the format of a valid
file path, with six trailing 'X's. • The parameter template must not have been used in a previous invocation of mkstemp.
Semantics • The trailing ''s in template are overwritten to generate a unique
file name for the resulting temporary file. • The function reports a valid
file descriptor to a
temporary file on success; on failure, it reports -1.
Example The following code is an example of the usage of mkstemp; the local variable filename is modified by mkstemp and will contain the path to the new file: • include void example() { char filename[] = "/tmp/prefXXXXXX"; int fd = mkstemp(filename); } ==Error conditions==