title: Rgd: How to pass unsigned char*&
body: <pre><code>#include &lt;string.h&gt;
  
  using namespace std;
  
  void rc4(unsigned char * ByteInput, unsigned char * pwd,
      unsigned char * &amp;ByteOutput){
      unsigned char * temp;
      int i,j=0,t,tmp,tmp2,s[256], k[256];
      for (tmp=0;tmp&lt;256;tmp++){
          s[tmp]=tmp;
          k[tmp]=pwd[(tmp % strlen((char *)pwd))];
      }
      for (i=0;i&lt;256;i++){
          j = (j + s[i] + k[i]) % 256;
          tmp=s[i];
          s[i]=s[j];
          s[j]=tmp;
      }
      temp = new unsigned char [ (int)strlen((char *)ByteInput) + 1 ] ;
      i=j=0;
      for (tmp=0;tmp&lt;(int)strlen((char *)ByteInput);tmp++){
          i = (i + 1) % 256;
          j = (j + s[i]) % 256;
          tmp2=s[i];
          s[i]=s[j];
          s[j]=tmp2;
          t = (s[i] + s[j]) % 256;
          if (s[t]==ByteInput[tmp])
              temp[tmp]=ByteInput[tmp];
          else
              temp[tmp]=s[t]^ByteInput[tmp];
      }
      temp[tmp]=' ';
      ByteOutput=temp;
  }
  
  int main()
  {
      unsigned char data[256] = "hello";
      unsigned char pwd[256] = "2147124912";
      unsigned char output[256];
      rc4(data,pwd,*output); 
  
      return 0;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>meme@ubuntu:~/CSCI368$ g++ try.cpp -o try
  try.cpp: In function ‘int main()’:
  try.cpp:42:20: error: invalid initialization of non-const reference of type ‘unsigned char*&amp;’ from an rvalue of type ‘unsigned char*’
  try.cpp:5:6: error: in passing argument 3 of ‘void rc4(unsigned char*, unsigned char*, unsigned char*&amp;)’
  </code></pre>
  
  <p>I am trying to compile but I think my argument 3 got problem <code>rc4(data,pwd,*output);</code></p>
  
  <p>How do I pass as <code>unsigned char*&amp;</code></p>