title: Is it possible to use write() in file opened with O_APPEND mode?
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;fcntl.h&gt;
  
  int main(){
      FILE * fp;
      char buf[128];
      int fd = open("/home/pdave/Downloads/ccode/fileout1",O_CREAT);
      printf("fd after creat:%d",fd);
      close(fd);
      fd = open("/home/pdave/Downloads/ccode/fileout1",O_APPEND);
      printf("fd after append:%d",fd);
      int more=1;
      int ret=0;
      while(more){
          puts("enter text:");
          scanf("%s",buf);
          puts(buf);
          ret=write(fd,buf,128);
          printf("ret:%d",ret);
          puts("more?");
          scanf("%d",&amp;more);
      }
  }
  </code></pre>
  
  <p>The above tries to write characters to a file opened with the open function in <code>O_APPEND</code> mode. It works when it is opened with <code>O_WRONLY</code> mode but not when it is opened in <code>O_APPEND</code>. How can I append to it without opening with "w" and then using seek to <code>SEEK_END</code> and then <code>fputs</code> to the file or something like that?</p>