title: How can I read and write from files using the headers fcntl.h and unistd.h?
body: <p>I'm trying to learn how to use the header files <code>&lt;fcntl.h&gt;</code> and <code>&lt;unistd.h&gt;</code>. I have created a small example to test the workings of their procedures, but it didn't work as expected. Here is my code:</p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  
  int main() {
    int in=open( "test.in", O_RDONLY, S_IREAD );
    int *a=new int[ 10 ];
    read( in, a, 10 );
    int out=open( "test.out", O_WRONLY, S_IWRITE );
    write( out, a, 10 );
    close( in ); close( out );
    return 0;
  }
  </code></pre>
  
  <p>The input file was: <code>1 2 3 4 5 6 7 8 9 10</code></p>
  
  <p>The program compiled normally, but it didn't create any output files. Could anyone tell me what is wrong with my code? Thanks in advance.</p>