creattemp
Creates a unique file in the directory associated with the path name.
Defined in header <dos.h>
Syntax
#include <dos.h>
int creattemp(char *path, int attrib);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
A file created with creattemp is always created in the translation mode specified by the global variable _fmode (O_TEXT or O_BINARY).
path is a path name ending with a backslash (\). A unique file name is selected in the directory given by path. The newly created file name is stored in the path string supplied, path should be long enough to hold the resulting file name. The file is not automatically deleted when the program terminates.
creattemp accepts attrib, a DOS attribute word. The file is always opened in binary mode. Upon successful file creation, the file pointer is set to the beginning of the file. The file is opened for both reading and writing.
The attrib argument to creattemp can be one of the following constants (defined in dos.h):
| FA_RDONLY | Read-only attribute |
| FA_HIDDEN | Hidden file |
FA_SYSTEM System file
Return value
Upon successful completion, the new file handle, a nonnegative integer, is returned; otherwise, -1 is returned.
In the event of error, the global variable errno is set to one of the following:
| ENOENT | Path or file name not found |
| EMFILE | Too many open files |
| EACCES | Permission denied |
See also
Example
#include <string.h>
#include <stdio.h>
#include <io.h>
int main(void)
{
int handle;
char pathname [128];
strcpy (pathname, "W");
/* create a unique file in the root directory */
handle = creattemp (pathname, 0);
printf("%s was the unique file created.\n", pathname);
close(handle);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dos.h/creattemp/
· short form /3.1/creattemp/