Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdio.h>
    char *tmpnam( char *buffer );
    wchar_t *_wtmpnam( wchar_t *buffer );

Description:
    The tmpnam function generates a unique string for use as a valid file
    name.  The _wtmpnam function is identical to tmpnam except that it
    generates a unique wide-character string for the file name.  An internal
    static buffer is used to construct the filename.  Subsequent calls to
    tmpnam reuse the internal buffer.

    The function generates unique filenames for up to  TMP_MAX calls.

Returns:
    If the argument buffer is a NULL pointer, tmpnam returns a pointer to an
    internal buffer containing the temporary file name.  If the argument
    buffer is not a NULL pointer, tmpnam copies the temporary file name from
    the internal buffer to the specified buffer and returns a pointer to the
    specified buffer.  It is assumed that the specified buffer is an array
    of at least  L_tmpnam characters.

    If the argument buffer is a NULL pointer, you may wish to duplicate the
    resulting string since subsequent calls to tmpnam reuse the internal
    buffer.


         char *name1, *name2;

         name1 = strdup( tmpnam( NULL ) );
         name2 = strdup( tmpnam( NULL ) );


Example:
    #include <stdio.h>

    void main()
      {
        char filename[ L_tmpnam ];
        FILE *fp;

        tmpnam( filename );
        fp = fopen( filename, "w+b" );
        /* . */
        /* . */
        /* . */
        fclose( fp );
        remove( filename );
      }

Classification:
    tmpnam is ANSI, _wtmpnam is not ANSI

Systems:
     tmpnam - All, Netware

    _wtmpnam - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    fopen, freopen, _mktemp, _tempnam, tmpfile

See Also: tmpfile

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson