Is it legal to convert char* type to unsigned char* type?
does the conversion from char* to unsigned char* cause any loss of data,
including length?
I've got a function named build which takes a unsigned char* and its length.
when I read raw data directly from disk like :
fseek(fp, 0, SEEK_END);
long lSize = ftell(fp);
rewind(fp);
BYTE * buf = (BYTE*) malloc(sizeof(unsigned char)*lSize);
then pass buf and lSize to build , it totally works.
However, when I hard code the content in the source like :
string origin= "this is a text";
long lSize = origin.size();
unsigned char *buf = (unsigned char*) malloc(sizeof(unsigned
char)*lSize);
char *strs = const_cast<char*>(origin.data());
buf = reinterpret_cast<unsigned char*>(strs);
it failed .
[Non-text portions of this message have been removed]