creattemp - create a temporary file


int creattemp (prefix, result, pmode, oflags) char *prefix; char *result; int pmode; int oflags;


This function generates a unique file name and creats a file by that name. Creattemp normally creates the temporary file in the /tmp directory on UNIX machines, and in \cbase\tmp on MS-DOS machines. If the environment variable TMPDIR is defined, this names the directory for the temporary file. The file name consists of an optional prefix and an internally generated unique suffix. Prefix may be NULL or point to a null terminated string of up to two characters to insure that the generated names are valid on MS-DOS machines. The complete path name is returned in result, which must be the address of a character array of at least L_tempname bytes, where L_tempname is a constant defined in . Creattemp creates the temporary file with the permission modes (pmode) specified in the same manner as the creat(2) call, and returns a file descriptor. The oflags parameter specifies additional "open" modes; typically used to specify O_TEXT or O_RAW in MS-DOS. Although oflags is currently ignored in UNIX, you should specify O_TEXT or O_RAW for portability. O_TEXT and O_RAW are defined in the include file . RETURN VALUE Creattemp returns the file descriptor of the newly created temporary file, or -1 if the file could not be created.





Creattemp returns a different file name each time it is called. You must close the file with close(2) and remove it with unlink(2) after you are done with it.