previous | start | next

Creating a new file

To open a new file for writing use the O_WRONLY flag, but bitwise or it with O_CREAT (no E at the end).

Open foo.txt as a new file (if it doesn't already exist) with permission 0600 (read/write for owner only):

        int fd;
        fd = open("foo.txt", O_WRONLY | O_CREAT, 0600);
     


previous | start | next