Hello,

I am just experimenting with some code. And I am not sure why I need to cast to an unsigned char*.

I get this error: cannot convert from 'unsigned char' to 'unsigned char *'
I can understand that the pointer is an unsigned char. But if I am assigning the address of the myFloat which I am casting a unsigned char. Why do I need to cast it as a pointer as well?

Code:
float myFloat = 10000;
unsigned char *ptrChar;
ptrChar = (unsigned char *) &myFloat;

//Why can't I just do this?
ptrChar = (unsigned char) &myFloat;
The following example using a int:
Code:
int myInt = 1000;
int *ptrInt = &myInt;
As the pointer is an int and I am assigning the address of myInt this works perfectly ok.

However, with the example above I have converted to a unsigned char.

Many thanks for clearing this up.

Steve