title: Send raw binary data over C socket?
body: <p>I'm working on sending encrypted data over sockets in C. Everything works fine until I realized that the size of the data being sent is much larger than what it supposed to be. The piece of code below describes the situation:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt; 
  #include &lt;string.h&gt;
  
  int main() {
      char temp[100], buffer[100];
      int n = 1234567890;
      sprintf(temp, "%d", n);
      printf("Original n has size: %d\n", sizeof(n)); // 4
      printf("Buffer size: %d\n", strlen(temp));      //10
      printf("Buffer: %s", temp);
  }
  </code></pre>
  
  <p>The problem is the original number is stored as a 4-byte integer, while the buffer is stored character by character, so what is going to be sent through the socket is not 4 bytes, but 10s of one byte character.</p>
  
  <p>I wonder is there any way to send binary data as raw?</p>