title: Open file in linux. I don't want to create a write-protected file
body: <p>I have a problem when I create a file in Linux it makes my file write-protected and I don't know why it does that. </p>
  
  <pre><code>void fileOperation::openFileWrite(char x, off_t s)
  {
    int fd;
    char c[2] = {x};
  
    fd = open("/home/stud/txtFile", O_CREAT | O_WRONLY);  //open file
    if(fd == -1)
        cout &lt;&lt; "can't open file" &lt;&lt; endl;
    else
    {
        lseek(fd, s, SEEK_SET);//seek at first byte
        write(fd, (void*)&amp;c, 2);//write to file
    }
    syncfs(fd);
    ::close(fd);
  }
  </code></pre>