Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>tempnam() generate a temporary file name in given directory</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 tempnam()               Generate a Temporary File Name in Given Directory

 #include   <stdio.h>

 char       *tempnam(dir,prefix);
 char       *dir;
 char       *prefix;

    tempnam() creates a temporary file name, for which 'prefix' is the
    prefix to the file name, in another directory.  In order, tempnam()
    looks for the file name in the following directories:

                 Condition                           Directory Used

            TMP environment variable is set        Directory specified by TMP
            and directory specified by TMP
            exists.

            TMP environment variable not set,      The 'dir' argument to
            or directory specified by TMP          tempnam()
            does not exist.

            The 'dir' argument is NULL, or         P_tmpdir in stdio.h
            'dir' is name of nonexistent
            directory.

            P_tmpdir does not exist.               Current directory

    Returns:    A pointer to the name generated.  A NULL value is
                returned if the name cannot be created or it already
                exists.

   -------------------------------- Example ---------------------------------

    The following statements create a temporary file name to be used as a
    file in another directory.  The file is opened,  data is entered and
    the file is closed.

           #include <stdio.h>

           char *tname;
           int x;
           FILE *in;

           main()
           {
               if ((tname = tempnam("c:\\","std")) != NULL) {
                     printf("temp file name : %s created\n",tname);
                     in = fopen(tname,"w+");
                     for (x = 0; x < 26; x++)
                         fprintf(in,"%d ",x);
                     fclose(in);
               }
               else
                     printf("can't make temp file\n");
           }



See Also: mktemp() tmpfile()

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