title: Read only one file, and write only another with open()
body: <p>I need to read only one file and write only another file.</p>
  
  <p>I tried to write some code, but there is a lot of errors.</p>
  
  <p>There is my come:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  
  int f_open(const char *name);
  int f_write(const char *name, int oflag, mode_t mode);
  
  
  int f_open(const char *name){
     int dskr;
     dskr = open( name, O_RDONLY );
     if( dskr == -1 ){
        perror( name );
        exit(1);
     }
     printf( "dskr = %d\n", dskr );
     return dskr;
  }
  
  int f_write(const char *name, int oflag, mode_t mode){
     int dskr;
     dskr = write( name, O_WRONLY | O_CREAT | O_TRUNC, 0644 );
     if( dskr == -1 ){
        perror( name );
        exit(1);
     }
     printf( "dskr = %d\n", dskr );
     return dskr;
  }
  
  int main( int argc, char *argv[] ){
     int d;
     int f;
     if( argc != 2 ){
        printf( "Naudojimas:\n %s failas_ar_katalogas\n", argv[0] );
        exit( 255 );
     }
     d = f_open( argv[1] );
     f = f_write( argv[2] );
     return 0;
  }
  </code></pre>
  
  <p>Everything I got is errors:</p>
  
  <pre><code>edgals_rw01.c: In function ‘f_write’:
  edgals_rw01.c:29:4: warning: passing argument 1 of ‘write’ makes integer from pointer without a cast
  /usr/include/unistd.h:532:16: note: expected ‘int’ but argument is of type ‘const char *’
  edgals_rw01.c:29:4: warning: passing argument 2 of ‘write’ makes pointer from integer without a cast
  /usr/include/unistd.h:532:16: note: expected ‘const void *’ but argument is of type ‘int’
  edgals_rw01.c: In function ‘main’:
  edgals_rw01.c:54:4: error: too few arguments to function ‘f_write’
  edgals_rw01.c:27:5: note: declared here
  </code></pre>