VMS Help  —  CRTL  tempnam
    Constructs the name for a temporary file.

    Format

      #include  <stdio.h>

      char *tempnam  (const char *directory, const char

                     *prefix, . . . ;)

1  –  Arguments

 directory

    A pointer to the pathname of the directory where you want to
    create a file.

 prefix

    A pointer to an initial character sequence of the filename. The
    prefix argument can be null, or it can point to a string of up
    to five characters used as the first characters of the temporary
    filename.

  . . .

    An optional argument that can be either 1 or 0. If you specify 1,
    tempnam returns the file specification in OpenVMS format. If you
    specify 0, tempnam returns the file specification in UNIX style
    format.

2  –  Description

    The tempnam function generates filenames for temporary files. It
    allows you to control the choice of a directory.

    If the directory argument is null or points to a string that is
    not a pathname for an appropriate directory, the pathname defined
    as P_tmpdir in the <stdio.h> header file is used. For programs
    running under a detached process, the directory argument cannot
    be null.

    You can bypass the selection of a pathname by providing the
    TMPDIR environment variable in the user environment. The value
    of the TMPDIR variable is a pathname for the desired temporary
    file directory.

    Use the prefix argument to specify a prefix of up to five
    characters for the temporary filename.

    The tempnam function returns a pointer to the generated pathname,
    suitable for use in a subsequent call to the free function.

    See also free.

                                   NOTE

       In contrast to tmpnam, tempnam does not have to generate
       a different filename on each call. tempnam generates a new
       filename only if the file with the specified name exists. If
       you need a unique filename on each call, use tmpnam instead
       of tempnam.

3  –  Return Values

    x                  A pointer to the generated pathname, suitable
                       for use in a subsequent call to the free
                       function.
    NULL               An error occurred; errno is set to indicate
                       the error.
Close Help