title: How to read a large file with function read() in C
body: <p>Aloha,</p>
  
  <p>I'm new here, so please take it easy on me.
  I'm trying to read a file with function <code>read()</code> and then <code>write()</code> to a file or a  file descriptor. My function successfully reads a file, but a problem occurs when I try to read a larger file(in my example size of 40,000 bytes).</p>
  
  <p>I think that I must write a while loop, which will be reading until the end of a file, but I am stuck on the idea of how to..</p>
  
  <p>(I open a file or file descriptor in main of the program)</p>
  
  <p>My function( also convert binary input char data and writes to the ASCII) :</p>
  
  <pre><code>void function(int readFrom,int writeOn){
      char buffer[100];
      int x = read(readFrom, buffer, sizeof(buffer));
      int size= x/8;
      int i;
      for(i=0; i&lt;size; i++){
          char temp[sizeof(int)-1];
          sprintf(temp,"%d",buffer[i];
          write(writeOn, temp, sizeof(temp));
      }
  }
  </code></pre>