title: Basic read/write clarification in C
body: <p>I'm trying to understand how to read and write in C. Would this store entries from the binary file into the buffer until the end of file.</p>
  
  <pre><code>unsigned char *buffer = (char*) malloc (sizeof(char) * SIZE);
  FILE *file = fopen(FILEPATH, "rb");
  if(file == NULL){
      //error
  } else {
      while(!feof(file)){
          fread(&amp;buffer, SIZE*sizeof(char), 1, file);
          // Print out buffer (should be different everytime assume I have different numbers in the file)
      }
  }
  </code></pre>
  
  <p>Or would I have to use fseek somewhere there?</p>
  
  <p>Vice-versa to write something to a document would this work? Thanks</p>
  
  <pre><code>unsigned char *buffer = (char*) malloc (sizeof(char) * SIZE);
  FILE *file = fopen(FILEPATH, "wb");
  for(int i=0; i&lt;SIZE; i++){
      // put something into buffer based on i
      fwrite(&amp;buffer, SIZE*sizeof(char), 1, file);
  }
  </code></pre>