title: Ignore \0 chars when writing to file C
body: <p>I am writing simple server - client app. On server side I receive char arrays of data (with const size). However last char array can have empty bytes.</p>
  
  <p>I append recieved array to file in loop. Here is code:</p>
  
  <pre><code>char buffer[256];
  /* ...  */
  FILE *file;
  file = fopen(file_name,"ab+");
  for (i = 0; i &lt; parts; ++i) {
      if ((length = recv(sockfd, buffer, 256, 0)) &lt; 0) {
          /* recv failed  */
      }
      send(sockfd, "OK", 2, 0);
      fwrite(buffer, 1, 256, file);
  }
  fclose(file);
  </code></pre>
  
  <p>for example:
  ... Quisque dignissim turpis sapien, non facilisis risus gravida at. <strong>\00\00\00\00</strong></p>
  
  <p>Is there any way how to skip last \0 chars? Or do I have to copy last array byte by byte. </p>