Apr 22, 2009 at 12:09pm UTC
Hi,
I'm facing a problem in converting a char* to unsigned char* and vise versa.
eg:
char *final = new char[100];
strcpy(final,"hiiiii");
unisgned char *input=new char[100];
input=*final; //Giving problem
and i want to do vise versa..
can any one help me in this?
Apr 22, 2009 at 12:26pm UTC
char *final = new char[100];
strcpy(final,"hiiii");
unsigned char* input = new char [100];
// very wrong... these are memory address...
//input = *final;
//copy data to destination...
memcpy((void*)input, (void*)final, strlen(hiiii));
Apr 22, 2009 at 5:30pm UTC
---
Last edited on May 9, 2009 at 6:31am UTC
May 8, 2009 at 9:59am UTC
sorry, i did not understand
May 9, 2009 at 6:34am UTC
do this:
input = final;
but what exactly you want to do??? this doesnt look you are trying to convert char to unsigned char.
this is not coping.. and there is a memory leak also. as input has lost its address.