title: Converting to integer from char buffer in sockets
body: <p>Client Side: </p>
  
  <pre><code>char buf[1024];  
  int packetAmt = fileSize/PACKETSIZE;
  cout&lt;&lt;"Number of packet amounts: "&lt;&lt;packetAmt&lt;&lt;endl; 
  
  // send packet amount to serv
  ibytessent=send(s,itoa(packetAmt,buf,10),sizeof(buf),0);   
  </code></pre>
  
  <p>Server side: </p>
  
  <pre><code>char szbuffer[1024];
  if((ibytesrecv = recv(s1,szbuffer,sizeof(szbuffer),0)) == SOCKET_ERROR)
       throw "Receive error in server program\n";
  cout &lt;&lt; "This is the number of packets sent: " &lt;&lt; szbuffer &lt;&lt; endl;
  packetAmt=atoi(szbuffer);
  cout &lt;&lt; "This is the number of packets sent: " &lt;&lt; packetAmt&lt;&lt; endl;
  </code></pre>
  
  <p>The integer returned after converting the char array into integer's doesn't match the string sent. However printing the string will return the correct value.  I have also tried using the strtol function. Could the error occur when converting from integer to char array?</p>