mktemp
raw OCR
Makes a unique file name.
Defined in header <dir.h>
Syntax
#include <dir.h>
char *mktempCchar *template);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ |
Remarks
mktemp replaces the string pointed to by template with a unique file name and returns template.
template should be a null-terminated string with six trailing Xs. These Xs are replaced with a unique collection of letters plus a period, so that there are two letters, a period, and three suffix letters in the new file name.
Starting with AA.AAA, the new file name is assigned by looking up the name on the disk and avoiding pre-existing names of the same format.
Return value
If template is well-formed, mktemp returns the address of the template string. Otherwise, it returns null.
Example
include <dir.h>
#include <stdio.h>
int main(void)
{
/* fname defines template for temporary file */
char *fname = "TXXXXXX", *ptr;
ptr = mktemp(fname);
printf("%s\n",ptr);
return 0;
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `mktennp` read as `mktemp`
Stable link: /3.1/dir.h/mktemp/
· short form /3.1/mktemp/