tempnam

Constructs the name for a temporary file.

Format

#include  <stdio.h>

char *tempnam  (const char *directory, const char
               *prefix);

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.

Description

This 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.

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 5 characters for the temporary filename.

See also free in this section.

Return Values
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. 


Previous Page | Next Page | Table of Contents | Index