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 - <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 a temporary file and returns a pointer to that
    file.  The temporary file is opened in "w+" mode (opened for reading
    and writing).  If not closed by a call to rmtmp(), the temporary file
    is automatically closed when the program terminates normally.

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

  -------------------------------- 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);
                 rmtmp();
             }
             else
                 printf("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