◄Up► ◄Contents► ◄Index► ◄Back► ─────Run-Time Library─────────────────────────────────────────────────────── /* TEMPNAME.C illustrates: * tmpnam _tempnam */ #include <stdio.h> void main() { char *name1, name2[L_tmpnam], *name3; int c; /* Create several temporary file names using internal buffer. */ for( c = 0; c < 5; c++ ) if( (name1 = tmpnam( NULL )) != NULL ) printf( "%s is a safe temporary file name.\n", name1 ); /* Create a temporary file name using external buffer. */ if( tmpnam( name2 ) != NULL ) printf( "%s is a safe temporary file name.\n", name2 ); /* Create a temporary file name with prefix TEMP and place it in * the first of these directories that exists: * 1. TMP environment directory * 2. C:\TEMPFILE * 3. P_tmpdir directory (defined in stdio.h) */ if( (name3 = _tempnam( "C:\\TEMPFILE", "TEMP" )) != NULL ) printf( "%s is a safe temporary file name.\n", name3 ); } -♦-