C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
_mktemp
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The _mktemp function creates a unique filename by modifying the
     given <template> argument. The <template> argument has the form
 
          baseXXXXXX
 
     where <base> is the part of the new filename supplied by the user
     and the Xs are placeholders for the part supplied by _mktemp. The
     _mktemp function preserves <base> and replaces the six trailing Xs
     with an alphanumeric character followed by a five-digit value. The
     alphanumeric character is 0 the first time _mktemp is called
     with a given template. The five-digit value is a unique number
     identifying the calling process.
 
     In subsequent calls from the same process with the same template,
     _mktemp checks to see if previously returned names have been used
     to create files. If no file exists for a given name, _mktemp
     returns that name. If files exist for all previously returned
     names, _mktemp creates a new name by replacing the alphanumeric
     character in the name with the next available lowercase letter.
 
     For example, if the first name returned is t012345 and this name
     is used to create a file, the next name returned will be ta12345.
     When creating new names, _mktemp uses, in order, '0' and then the
     lowercase letters 'a' to 'z'.
 
     Note that the original template is modified by the first call to
     _mktemp. If you then call the _mktemp function again with the same
     template (that is, the original one), you get an error.
 
     The _mktemp function generates unique filenames but does not
     create or open files.
 
     Return Value
 
     The _mktemp function returns a pointer to the modified template.
     The return value is NULL if the template argument is badly formed
     or no more unique names can be created from the given template.
                                    -♦-