home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / ansi / stdio / tmpnam.txh < prev    next >
Encoding:
Text File  |  1995-07-10  |  1.6 KB  |  44 lines

  1. @node tmpnam, stdio
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <stdio.h>
  6.  
  7. char *tmpnam(char *s);
  8. @end example
  9.  
  10. @subheading Description
  11.  
  12. This functions generates a string that is a valid file name and that
  13. is not the same as the name of an existing file.  A different string is
  14. guaranteed to be produced each time it is called, up to @code{TMP_MAX}
  15. times (@code{TMP_MAX} is defined on stdio.h).  If @code{tmpnam} is called
  16. more than TMP_MAX times, the behavior is implementation-dependent (ours
  17. just wraps around and tries to reuse the same file names from the
  18. beginning).
  19.  
  20. This function examines the environment to determine the directory in which
  21. the temporary file will be opened.  It looks for one of the variables
  22. @code{"TMPDIR"}, @code{"TEMP"} and @code{"TMP"}, in that order.  The first
  23. one which is found in the environment will be used on the assumption that
  24. it points to a directory.  If neither of the above variables is defined,
  25. @code{tmpnam} defaults to the "c:/" directory (which under MS-DOS might
  26. mean that it fails to generate TMP_MAX unique names, because DOS root
  27. directories cannot grow beyond certain limits).
  28.  
  29. @subheading Return Value
  30.  
  31. If @var{s} is a null pointer, @code{tmpnam} leaves its result in an
  32. internal static buffer and returns a pointer to that buffer.  If @var{s}
  33. is not a null pointer, it is assumed to point to an array of at least
  34. @code{L_tmpnam} characters, and @code{tmpnam} writes its result in that
  35. array and returns a pointer to it as its value.
  36.  
  37. @subheading Example
  38.  
  39. @example
  40. char buf[L_tmpnam];
  41. char *s = tmpname(buf);
  42. @end example
  43.  
  44.