Trouble with unsigned char *
<p>I am having trouble with unsigned char *. Here is my code:</p>

<pre><code>unsigned char *str=NULL;
str= (unsigned char*) realloc(str, 10*sizeof(unsigned char));
int number=10;
str[0]=(unsigned char) number;
</code></pre>

<p>Whenever I try to see str[0] with cout, it shows something else other than 10. I also have trouble when putting other variable into str:</p>

<pre><code>unsigned char c='c';
str[0]=c;
cout&lt;&lt;str[0];
</code></pre>

<p>str[0] would output a. What am I missing?</p>
