title: c++ return array of unsigned char
body: <p>I have this function:</p>
  
  <pre><code>    unsigned char* encrypt_decrypt( unsigned char* text,unsigned char* pass)
      {
         unsigned char *s=(unsigned char*)malloc(strlen((char*)text+1)*sizeof(unsigned char));
         int length=strlen((char*)text);
         printf("chestii:%d",sizeof(s));
         for(int i=0;i&lt;length;i++)
         {
  
          s[i]=text[i]^pass[i];
          printf("text:%d\n",text[i]);
          printf("pass:%d\n",pass[i]);
          printf("cript:%d\n",s[i]);
         }
         s[length]='\0';
  
         return s;
      }
  </code></pre>
  
  <p>The text and pass have the exact length and the s pointer should have the same length as the text at the end of the function.For example let's say that the text and pass have 26 characters.I don't know why but at the end of the for instruction,the length of the s pointer is only 10.I allocated enough memory and I think i put 26 elements in s.Please help me figure out why strlen(s) is only 10 ?</p>