title: C File Descriptor is returning -1 on open
body: <p>Embarrassingly simple question, but I can't seem to open a new file for writing using a file descriptor. Every variation I've tried returns <code>-1</code>. What am I missing? This is how you initialize a file using file descriptors, correct? I can't find documentation that states otherwise.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  
  int main()
  {
    int fd;
    mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
    fd = open ("/home/CSTCIS/sample.dat", O_WRONLY, mode);
    printf("%d\n", fd);
  }
  </code></pre>
  
  <p>perror() prints <code>open: No such file or directory</code>.</p>