title: creating a buffer/packet in c++
body: <p>I am trying to test something and I need to assume that the input is from a client using TCP and that the data is a buffer or maybe a byte array.</p>
  
  <p>So this is my try:</p>
  
  <blockquote>
    <p>unsigned char buf[] = { 99, 249, 117, 130, 110, 227, 171, 204, 30, 201,
    225, 130, 203, 206, 74, 88, 94, 12, 223, 172, 60, 12, 173, 26, 145,
    163, 112, 124, 99, 239, 188, 98, 103, 85, 163, 135, 125, 140, 186,
    220, 207, 35, 185, 14, 22, 58, 36, 239, 124, 107, 29, 27, 44, 246, 165
    };</p>
  </blockquote>
  
  <p>So assuming that is from the client. I would like to test to process it:</p>
  
  <pre><code>xor256.Decrypt(buf, result, sizeof(buf));
  </code></pre>
  
  <p>But <code>Decrypt</code> is:</p>
  
  <pre><code>void XOR256::Decrypt(char const* in, char* result, size_t n)
  </code></pre>
  
  <p>So how do I fix this?</p>
  
  <p>Problems:</p>
  
  <ul>
  <li><p>Cannot initialise a variable of type <code>const char *</code> with an lvalue of type <code>unsigned char[55]</code></p></li>
  <li><p>I am confused with this. I want to get the result but this function does not return anything. But it points data to <code>result</code>. So how do I get the data?</p></li>
  <li><p>I'm new to C++</p></li>
  </ul>
  
  <hr>
  
  <pre><code>int main(int argc, const char * argv[])
  {
      CXOR256Stream xor256;
  
      char *nkey = new char[256];
  
      int a = 111;
      int b = 222;
  
      memset(nkey, 0x00, 256);
      sprintf((char*)nkey, "%.5d_XXX%.5d_XXX_%.5d", (a+10), (b+10), (a+b));
  
  
      unsigned char s[] = { 99, 249, 117, 130, 110, 227, 171, 204, 30, 201, 225, 130, 203, 206, 74, 88, 94, 12, 223, 172, 60, 12, 173, 26, 145, 163, 112, 124, 99, 239, 188, 98, 103, 85, 163, 135, 125, 140, 186, 220, 207, 35, 185, 14, 22, 58, 36, 239, 124, 107, 29, 27, 44, 246, 165 };
  
      const char* buf = s; // error here
      char result[50];
  
      xor256.Initialize(nkey, 256, 2);
      xor256.Decrypt(buf, result, sizeof(buf));
  
      // no error here but I'm confused on getting the data from decrypt so is this right?
      cout &lt;&lt; result &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>