3.4. creat FunctionA new file can also be created by calling the creat function.
Note that this function is equivalent to open (pathname, O_WRONLY | O_CREAT | O_TRUNC, mode);
We'll show how to specify mode in Section 4.5 when we describe a file's access permissions in detail. One deficiency with creat is that the file is opened only for writing. Before the new version of open was provided, if we were creating a temporary file that we wanted to write and then read back, we had to call creat, close, and then open. A better way is to use the open function, as in open (pathname, O_RDWR | O_CREAT | O_TRUNC, mode); |