I am trying to create a write only file in C on Linux (Ubuntu). This is my code:
int fd2 = open (\"/tmp/test.svg\", O_RDWR|O_CREAT);
if (fd2 != -1) {
//...
Give access permissions as the third parameter:
int fd2 = open("/tmp/test.svg", O_RDWR|O_CREAT, 0777); // Originally 777 (see comments)
if (fd2 != -1) {
// use file descriptor
close(fd2);
}
By doing this, all read, write and execute permissions will be given to user, group and others. Modify the 3rd parameter according to your use.