tmpnam

Creates a name for a temporary file.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  char *tmpnam (
     char  *string);
  

Parameters

string

(OUT) Points to the buffer to receive the generated temporary filename. This buffer should be at least L_tmpnam bytes, a constant defined in stdio.h.

Return Values

If string parameter is not a NULL pointer, returns string.

If string parameter is a NULL pointer, tmpnam creates the temporary filename in an internal static buffer and returns a pointer to that buffer. The next call to tmpnam overwrites the contents in this internal buffer.

Remarks

Be aware that the internal static buffer is modified every time tmpnam is called, whether or not you pass a NULL pointer. If you want to preserve the temporary filename currently stored in the internal static buffer, copy it to another buffer (by calling the strcpy function) before calling tmpnam again.

If you pass a pointer to your created array, tmpnam leaves the temporary filename in that array and returns a pointer to it. tmpnam simply returns the pointer you have supplied. It does no error checking to ensure that your array is big enough to accommodate the filename. The array should be at least L_tmpnam characters in length.

See Also