home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / TMPFILE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  1.6 KB  |  46 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - tmpfile.c
  3.  *
  4.  * function(s)
  5.  *        tmpfile - creates a unique temporary file
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18.  
  19. #include <stdio.h>
  20. #include <_stdio.h>
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name            tmpfile - creates a unique temporary file
  25.  
  26. Usage           #include <stdio.h>
  27.                 FILE *tmpfile(void);
  28.  
  29. Prototype in    stdio.h
  30.  
  31. Return value    On successful completion, the associated stream.
  32.                 In the event of error, NULL is returned.
  33.  
  34. *---------------------------------------------------------------------*/
  35. FILE *tmpfile(void)
  36. {
  37.         FILE    *stream;
  38.         char    *s;
  39.  
  40.         s = tmpnam(NULL);       /* Get a unique file name */
  41.         if ((stream = fopen(s, "w+b")) != NULL)
  42.                 stream->istemp = _tmpnum;
  43.  
  44.         return (stream);
  45. }
  46.