title: send and read string between threads
body: <p>This has been killing me and my lack of experience with c/c++ is the reason.</p>
  
  <p>I cannot figure out how to read a string in from another thread. In this case the thread is coming from a client who is connected to a server thread. I have been able to pass ints without any problem. Can't seem to figure out how to get strings passed however.</p>
  
  <p>client side who reads in the string from the console and needs to send to server:</p>
  
  <pre><code>cout &lt;&lt; "Enter in an operation and number: \n ";
  int x;
  char str[20];
  int len = strlen(str);
  int result;
  
  
  cin&gt;&gt;str;
  cin&gt;&gt;x;
  
  write(client_sock, &amp;len, sizeof(int));
  write(client_sock, str, len);
  write(client_sock, &amp;x, sizeof(x));
  
  read(client_sock, &amp;result, sizeof(result));
  cout&lt;&lt;result;
  </code></pre>
  
  <p>server side that needs to read string, for testing I am trying to send it back however I need to read it in and compare it to other conditions to carryout operations on the numbers I read in.</p>
  
  <pre><code>int result;
  int input;
  int len;
  char str;
  
  read(client_sock, &amp;input, sizeof(input));
  read(client_sock,&amp;len,sizeof(len));
  char buf[sizeof(len)];
  sscanf(buf, "%s", &amp;str);
  
  cout&lt;&lt;str;
  result= input*input;
  
  write(client_sock,&amp;result,sizeof(result));
  write(client_sock, buf, strlen(buf));
  </code></pre>
  
  <p>of course this is an assignment, my professor told me to read in characters into a buffer and null terminate it. I am not sure what he means by null terminating.. also am i correctly reading into the buffer?</p>