[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
creat

Create a new file or overwrite an existing file.
Compatibility:
This function is compatible with the following targets:
Prototype:
#include <fcntl.h>
int creat(const char *filename, int mode);
Parameters:
Parameters for this facility are:
Remarks:
This function creates a file named filename you can write to. If the file does not exist, creat() creates it. If the file already exists, creat() overwrites it. The function ignores the argument mode.
This function call:
  creat(path, mode);
is equivalent to this function call:
  open(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
Return:
If it's successful, creat() returns the file description for the created file. If it encounters an error, it returns -1.
See Also:
"fopen"
"fdopen"
"open"
"close".
Example of creat() usage.:
#include <stdio.h>
#include <unix.h>
int main(void)
{
int fd;
fd = creat("Jeff:Documents:mytest", 0);
/* Creates a new file named mytest in the folder
Documents on the volume Akbar. */
write(fd, "Hello world!\n", 13);
close(fd);
return 0;
}
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 16, 2000