#include <stdio.h> char *tmpnam(char *buf);
tmpnam
generates a string that is a valid filename and is not
the same as the name of any existing file. If a file with this name
is opened, it continues to exist after program termination. tmpnam
generates up to TMP_MAX
filenames, a different name each time it is
called.
For a program compiled with the posix
option, the name returned by
tmpnam
defines a file in the HFS directory /tmp
.
buf
is NULL
, tmpnam
leaves its result in an internal
static object and returns a pointer to that object. Subsequent calls to
tmpnam
may modify that same object.
If buf
is not NULL
, it is assumed to point to an array of at least
L_tmpnam
characters; tmpnam
writes its result in that array and
returns the argument as its value.
tmpnam
. If
after 100 attempts it cannot generate a unique filename, tmpnam
returns
NULL
.
TMP_MAX
because it is virtually impossible to cause an error by calling tmpnam
too many times.
The returned filename strings are composed as follows:
MVS
dsn:uHere is an example:serid.jobid.
$ddmonyr.
$hhmmss.
$tens-of-microseconds
dsn:GEORGE.JOB01234.$10NOV88.$142253.$0000792If a userid is not available, use
"C-TMP"
. Here is an example:
dsn:C-TMP.JOB01234.$10NOV88.$142253.$0000792CMS
cms:$Here is an example:ddmonyr
$tens-of-microseconds fml
cms:$10NOV88 $0000792 A1
The CMS filemode letter is chosen from the read and write disk with the most space.
OpenEdition
/tmp/logonid.pid.ddmonyr.hhmmss.tens-of-microseconds
For example:
/tmp/JANE.524290.10NOV94.142253.0000792
#include <stdio.h> #include <stdlib.h> main() { char *name; FILE *temp; name = tmpnam(NULL); if (name == NULL) exit(EXIT_FAILURE); temp = fopen(name, "w"); fputs("Hello, temporary world.n", temp); fclose(temp); remove(name); }
tmpfile
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.