home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / CLIBSRC1.ZIP / TMPFILE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.2 KB  |  50 lines

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