mkstemp

Constructs a unique filename.

Format

#include  <stdlib.h>

int mkstemp  (char *template);

Arguments

template
A pointer to a string that is replaced with a unique filename. The string in the template argument must be a filename with six trailing Xs.

Description

This function replaces the six trailing Xs of the string pointed to by template with a unique set of characters, and returns a file descriptor for the file open for reading and writing.

The string pointed to by template should look like a file name with six trailing X's. The mkstemp function replaces each X with a character from the portable file-name character set, making sure not to duplicate an existing file name.

If the string pointed to by template does not contain six trailing Xs, -1 is returned.

Return Values
An open file descriptor. 
-1  Indicates an error. (The string pointed to by template does not contain six trailing Xs.) 


Previous Page | Next Page | Table of Contents | Index