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>tmpfile() create a temporary file</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 tmpfile()               Create a Temporary File

 #include   <stdio.h>

 FILE       *tmpfile(void);              Pointer to FILE structure

    tmpfile() creates and opens a temporary file in "wb+" (binary
    read/write mode) and returns a pointer to that file.   If not closed
    by a call to rmtmp(), fclose() or fcloseall(), the temporary file is
    automatically closed when the program terminates normally.

    Returns:    A pointer to the file, if successful.  If the file cannot
                be opened, a NULL pointer is returned.

 Compatibility: MSC version 4.0 opens the file in "w+" mode; the
                translation mode is set by the default mode varaible -
                fmode.
   -------------------------------- Example ---------------------------------

    The following statements create a temporary file, use the file, and
    then delete it.

           #include <stdio.h>

           FILE *stream;
           char *buffr = "copy this to stream";

           main()
           {
               if ((stream = tmpfile()) != NULL) {
                   fprintf(stream,"%s",buffr);
                   printf("temp file opened & string written to it.\n");
                   rmtmp();
               }
               else
                   perror("unable to open temporary file\n");
           }


See Also: tmpnam() tempnam() rmtmp() mktemp()

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