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

NAME

6       mktemp - make a unique filename (LEGACY)
7

SYNOPSIS

9       #include <stdlib.h>
10
11       char *mktemp(char *template);
12
13

DESCRIPTION

15       The  mktemp() function shall replace the contents of the string pointed
16       to by template by a unique filename and return template.  The  applica‐
17       tion  shall  initialize template to be a filename with six trailing 'X'
18       s; mktemp() shall replace each 'X' with a single  byte  character  from
19       the portable filename character set.
20

RETURN VALUE

22       The  mktemp()  function shall return the pointer template.  If a unique
23       name cannot be created, template shall point to a null string.
24

ERRORS

26       No errors are defined.
27
28       The following sections are informative.
29

EXAMPLES

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

APPLICATION USAGE

47       Between  the time a pathname is created and the file opened, it is pos‐
48       sible for some other process to create a file with the same  name.  The
49       mkstemp() function avoids this problem and is preferred over this func‐
50       tion.
51

RATIONALE

53       None.
54

FUTURE DIRECTIONS

56       This function may be withdrawn in a future version.
57

SEE ALSO

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