title: read socket from C
body: <p>When I use <code>read()</code> socket to retrieval bytes from server I found something unexpected in the chars.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>Char buf[80];
  Char output[80];
  if ( (count = read(socket_d, buf, 80)) == -1) {
          perror("Error on read call");
          exit(1);
      }
  strcat(output, buf);
  printf("Client read %d bytes\n", count);       
  while (count==80) {
      memset(&amp;buf, 0, sizeof(buf));
      if ( (count = read(socket_d, buf, 80)) == -1) {
          perror("Error on read call");
          exit(1);
      }
      printf("Client read %d bytes\n", count);
      strcat(output, buf);
  }
  /* print the received message */
  printf("\n%s\n\n", output);
  </code></pre>
  
  <p>The output as below:</p>
  
  <pre><code>Client read 80 bytes
  Client read 80 bytes
  Client read 8 bytes
  Your messages:
  1:From User1, 04/21/16 02:12 AM, MSG1
  2:From User2, 04/21/16 02:162 AM, MSG2
  3:From User2, 04/21/16 02:12 AM, MSG3
  4:From User1, 04/21/16 02:12 AM6, MSG4
  </code></pre>
  
  <p>The expect output should be:</p>
  
  <pre><code>Client read 80 bytes
  Client read 80 bytes
  Client read 8 bytes
  Your messages:
  1:From User1, 04/21/16 02:12 AM, MSG1
  2:From User2, 04/21/16 02:12 AM, MSG2
  3:From User2, 04/21/16 02:12 AM, MSG3
  4:From User1, 04/21/16 02:12 AM, MSG4
  </code></pre>
  
  <p>It seems that there is unexpected <code>char('6')</code> shown in <code>buf[]</code> in the second loop.</p>
  
  <p>As I define the size of each time <code>read()</code> socket, so I want to loop read until the read amount is less than the <code>limit_size</code>, then output.</p>
  
  <p>What should I do with the <code>buf[]</code> during the loop to avoid the unexpected chars?</p>