title: Concatenating char buffer into a string
body: <p>In the following snippet, I receive the data until I have completely received all the data from the socket client. I keep on storing the data in a char buffer of size 300.</p>
  
  <pre><code>ssize_t b;
  char buffer[300]
  while((b = recv(socket_fd,buffer,sizeof(buffer))) &gt; 0) {
     // keep on receiving the data
  
  }
  </code></pre>
  
  <p>But the problem is on each iteration, buffer gets refilled and old values are lost. How do I concatenate the buffer values into one, so that at the end of the loop I get the message as one complete string?</p>