I need this conversion, because I am working with libraries and want to keep their definitions, but have to make them working together.
so i have
functionX(uint8 *src, uint16 nSrcLen){
write(src);
}
write(const char msg){}
thanks for helping out 😉
edit: additional infos
functionX and write should, if anyway possible stay this way. However, regardless of this, I am interested in better solutions.
src will carry null-bytes
edit: write, how it used to be used
std::string hex_chars;
std::getline(std::cin, hex_chars);
std::istringstream hex_chars_stream(hex_chars);
unsigned int ch;
while (hex_chars_stream >> std::hex >> ch)
{
write(ch);
}
now, there is no need for the hex-conversion anymore, but I guess it is still necessary to use this stream-construction
edit: current solution
for(uint16 i = 0; i < nSrcLen; i++)
{
write(reinterpret_cast<unsigned char*>(src)[i]);
//printf("%d",reinterpret_cast<unsigned char*>(src)[i]);
}
works for me, for now – thank you guys!
To convert the pointer types, you just need to cast the pointer from one type to the other.
For example,
You can also do it the other way round:
For your function, you can use: