title: c++ how to add a zero bits byte or null to a string
body: <p>I am doing a simple client implementation of TFTP.
  Here i need to send read request in following format</p>
  
  <pre><code>/* send request 
  
        2 bytes    string     1 byte     string   1 byte
  ------------------------------------------------------
  RRQ/  | 01/02 |  Filename  |   0  |    Mode    |   0  |
  WRQ  -------------------------------------------------
  
  */
  </code></pre>
  
  <p>in between i have to insert 1 byte zero bits value . 
  But i am not able to add that value.
  Also if i add a 1 zero bits byte.. which actually means a string terminating character 
  than how to get proper strlen value.</p>
  
  <p>If any one can help me with this...</p>
  
  <pre><code>enter code here
  
  
  const char opcode_read[2] ={'0','1'};
  const char opcode_write[2] ={'0','2'};
  const char opcode_data[2] ={'0','3'};
  const char opcode_acknowledge[2] ={'0','4'};
  const char opcode_error[2] ={'0','5'};  
  const char mode_netascii[] = "netascii\0";
  char blk_read_request[100];
  char file_name[] = "rfc0791.txt\0";
  
  memcpy(blk_read_request, opcode_read, 2);
  memcpy(&amp;blk_read_request[2], file_name, strlen(file_name) + 1);
  memcpy(&amp;blk_read_request[2 + strlen(file_name)], mode_netascii, strlen(mode_netascii) + 1);
  
  for (int i = 0; i &lt; strlen(blk_read_request); i++) {
      cout &lt;&lt; i &lt;&lt; " : " &lt;&lt; blk_read_request[i] &lt;&lt; " " &lt;&lt; std::bitset&lt;CHAR_BIT &gt; (blk_read_request[i]) &lt;&lt; "\n";
  }
  </code></pre>