COHERENT manpages

This page displays the COHERENT manpage for mktemp() [Generate a temporary file name].

List of available manpages
Index


mktemp() -- General Function (libc)

Generate a temporary file name
char *mktemp(pattern) char *pattern;

mktemp() generates  a unique file  name.  It can  be used, for  example, to
name intermediate  data files.  pattern  must consist of a  string with six
X's at the  end.  mktemp replaces these X's with  the five-digit process id
of the requesting process and a  letter that is changed for each subsequent
call.  mktemp returns pattern. For example, the call

    char template[] = "/tmp/sortXXXXXX";
    mktemp(template);

might return the name /tmp/sort01234a.

It is normal practice to write temporary files into the directory /tmp. The
start of the file name identifies the originator of the file.

See Also

libc

Notes

Because  mktemp() writes  on  the argument  template, passing  it a  quoted
string causes a segmentation  violation.  To avoid this, either compile the
module that  contains the call to mktemp() with  the compiler option -VPSTR
(to  put the  quoted string  into  segment .data  rather than  into segment
.text) or, preferably, move the string into the data segment.  For example,
use

    char template[] = "/tmp/sortXXXXXX";
    mktemp(template);

rather than:

    mktemp("/tmp/sortXXXXXX");