| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- create a new file or rewrite an existing one
#include <sys/stat.h>#include <fcntl.h>intcreat(const char *path,mode_tmode);
The function call
creat(path, mode)
is equivalent to:
open(path, O_WRONLY | O_CREAT | O_TRUNC, mode)
Refer toopen(2).
Refer toopen(2).
Example 1 Creating a File
The following example creates the file/tmp/file with read and write permissionsfor the file owner and read permission for group and others. Theresulting file descriptor is assigned to thefd variable.
#include <fcntl.h>...int fd;mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;char *filename = "/tmp/file";...fd = creat(filename, mode);...
Thecreat() function has a transitional interface for 64-bit file offsets. Seelf64(5).
Seeattributes(5) for descriptions of the following attributes:
|
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |