mktemp(3) CLIX mktemp(3)
NAME
mktemp - Creates a unique filename
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
char *mktemp(
char *template );
PARAMETERS
template Points to a string of at least six characters. The final six
characters must all be Xs.
DESCRIPTION
The mktemp() function replaces the contents of the string pointed to by
template with a unique filename and then returns the address to template.
The string in template should look like a filename with six trailing Xs.
The mktemp() function replaces the Xs with a letter and the current
process ID. A unique letter is chosen so that the resulting name does not
duplicate an existing file.
EXAMPLES
This code fragment shows how the mktemp() function is typically used. The
mktemp() function replaces the contents of the string pointed to by
unique_name with a unique filename and returns the address of unique_name.
char name[8];
char unique_name[14];
/* get a unique temporary name */
strcpy(unique_name, name);
strcat(unique_name, "XXXXXX");
mktemp (unique_name);
CAUTIONS
If called more than 17,576 times in a single process, this function starts
recycling previously used names.
RETURN VALUES
The mktemp() function will assign to template the NULL string if it cannot
create a unique name. Otherwise, the unique name will be returned in
2/94 - Intergraph Corporation 1
mktemp(3) CLIX mktemp(3)
template.
RELATED INFORMATION
Functions: getpid(2), tmpfile(3), tmpnam(3)
2 Intergraph Corporation - 2/94