
Q: How can i convert a char* to unsigned char*
On Fri, 13 Oct 2000 12:50:56 +0100, Andreas Lander
Quote:
>Hi folks,
>i have the following problem:
>my compiler brings an error:
>cannot convert parameter 2 from char* to unsigned char*.
>how can i convert a char* to an unsigned char*?
You don't need to, you can tell the compiler to pretend your char * is
an unsigned char * using a typecast:
void SomeFunc(unsigned char *Data); // Prototype
int main(void)
{
char someData[16] = "My Data";
SomeFunc(someData); // Fails to compile
Quote:
}
The call to SomeFunc() in the example fails for the same reason your
code does in your case. You can change the SomeFunc call to:
SomeFunc((unsigned char *)someData);
This contains a typecast, a hint or lie to the compiler to tell it to
use the following object as though it were of the type in the
typecast.
In general typecasts are considered to be a last resort option that
often arises due to poor type control and design. However, in an
expansive API like Win32 it is common to need them.
Regards,
David.
--
Spam safe e-mail address (I hope), remove not. both
times it appears to contact me. I reserve the right
to respond only on a newsgroup if I choose.