Q: How can i convert a char* to unsigned char* 
Author Message
 Q: How can i convert a char* to unsigned char*

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*?

Thanks advance
Andreas Lander



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*


Fri, 19 Jun 1992 00:00:00 GMT  
 Q: How can i convert a char* to unsigned char*
Doesn't (unsigned char*) conversion work?
--
With the best regards
Eugene Petrik


ICQUIN: 56636768


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*?

> Thanks advance
> Andreas Lander



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*
No, the same error happens....cannot convert.....

thanks anyway

Quote:

> Doesn't (unsigned char*) conversion work?
> --
> With the best regards
> Eugene Petrik


> ICQUIN: 56636768



> > 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*?

> > Thanks advance
> > Andreas Lander



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*
What is this code?
There can be several ways to resolve your problem.
--
With the best regards
Eugene Petrik


ICQUIN: 56636768


Quote:
> No, the same error happens....cannot convert.....

> thanks anyway


> > Doesn't (unsigned char*) conversion work?
> > --
> > With the best regards
> > Eugene Petrik


> > ICQUIN: 56636768



> > > 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*?

> > > Thanks advance
> > > Andreas Lander



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*

 char *p;
 unsigned char *p2 = reinterpret_cast<unsigned char*>(p);

try to avoid char* and use STL or CString or your own char* wrapper

Sc


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*?

> Thanks advance
> Andreas Lander



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*


Fri, 19 Jun 1992 00:00:00 GMT  
 Q: How can i convert a char* to unsigned char*
Cast it.
If you pass a variable of type char * then casting to unsigned char *
is done this way :

char * string;

// Passing this string to some function as unsigned char *

Function((unsigned char *)string);

--
Vlatko Surlan --- Koma.
Web site : http://student.math.hr/~vsurlan/Web+.html



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*


Fri, 19 Jun 1992 00:00:00 GMT  
 Q: How can i convert a char* to unsigned char*
Thank you

with this solution works the conversation...

greetings from switzerland
Andreas

Quote:

>  char *p;
>  unsigned char *p2 = reinterpret_cast<unsigned char*>(p);

> try to avoid char* and use STL or CString or your own char* wrapper

> Sc



> > 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*?

> > Thanks advance
> > Andreas Lander



Tue, 01 Apr 2003 03:00:00 GMT  
 Q: How can i convert a char* to unsigned char*


Fri, 19 Jun 1992 00:00:00 GMT  
 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.



Tue, 01 Apr 2003 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Converting unsigned char to signed char invokes UB?

2. converting const char* to unsigned char[1024]

3. Convert from char to unsigned char

4. Newbie: Can not convert for char to unsigned char

5. Convert from char to unsigned char

6. Sorting a Huge Unicode File use strcmp(unsigned char *, unsigned char *)

7. char, unsigned char, signed char

8. Sorting a Huge Unicode File use strcmp(unsigned char *, unsigned char *)

9. Sorting a Huge Unicode File use strcmp(unsigned char *, unsigned char *)

10. How to convert unsigned long to unsigned char?

11. To convert unsigned char to unsigned short in VC++

12. To convert unsigned char to unsigned short in VC++

 

 
Powered by phpBB® Forum Software