Samiksha Jaiswal (Editor)

Mkstemp

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In computing, mkstemp is a POSIX function for creating a temporary file (a computer file which usually ceases to exist when the program, which opened the file, closes it or terminates).

Contents

Inclusion

C
C++

Declaration

int mkstemp(char* template);

Requirements

  • The parameter template must be a modifiable, null-terminated character array.
  • The contents of template must be in the format of a valid file path, with six trailing 'X's.
  • The parameter template must not have been used in a previous invocation of mkstemp.
  • Semantics

  • The trailing 'X's in template are overwritten to generate a unique file name for the resulting temporary file.
  • The function reports a valid file descriptor to a temporary file on success; on failure, it reports -1.
  • Error conditions

    It is unspecified if mkstemp sets errno, and what values of errno are set, in the event of failure.

    References

    Mkstemp Wikipedia