1MKTEMP(3P)                 POSIX Programmer's Manual                MKTEMP(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       mktemp - make a unique filename (LEGACY)
13

SYNOPSIS

15       #include <stdlib.h>
16
17       char *mktemp(char *template);
18
19

DESCRIPTION

21       The mktemp() function shall replace the contents of the string  pointed
22       to  by  template by a unique filename and return template. The applica‐
23       tion shall initialize template to be a filename with six  trailing  'X'
24       s;  mktemp()  shall  replace each 'X' with a single byte character from
25       the portable filename character set.
26

RETURN VALUE

28       The mktemp() function shall return the pointer template.  If  a  unique
29       name cannot be created, template shall point to a null string.
30

ERRORS

32       No errors are defined.
33
34       The following sections are informative.
35

EXAMPLES

37   Generating a Filename
38       The  following  example  replaces the contents of the "template" string
39       with a 10-character filename beginning with the characters  "file"  and
40       returns  a pointer to the "template" string that contains the new file‐
41       name.
42
43
44              #include <stdlib.h>
45              ...
46              char *template = "/tmp/fileXXXXXX";
47              char *ptr;
48
49
50              ptr = mktemp(template);
51

APPLICATION USAGE

53       Between the time a pathname is created and the file opened, it is  pos‐
54       sible  for  some other process to create a file with the same name. The
55       mkstemp() function avoids this problem and is preferred over this func‐
56       tion.
57

RATIONALE

59       None.
60

FUTURE DIRECTIONS

62       This function may be withdrawn in a future version.
63

SEE ALSO

65       mkstemp(),   tmpfile(),   tmpnam(),  the  Base  Definitions  volume  of
66       IEEE Std 1003.1-2001, <stdlib.h>
67
69       Portions of this text are reprinted and reproduced in  electronic  form
70       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
71       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
72       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
73       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
74       event of any discrepancy between this version and the original IEEE and
75       The Open Group Standard, the original IEEE and The Open Group  Standard
76       is  the  referee document. The original Standard can be obtained online
77       at http://www.opengroup.org/unix/online.html .
78
79
80
81IEEE/The Open Group                  2003                           MKTEMP(3P)
Impressum