您需要将其转换为您用于"无符号字节"的相应类型.一旦适当地进行了渲染,您就可以像访问数组一样访问它(访问元素).
unsigned char* bytePointer = static_cast<unsigned char*>(originalVoidPointer);
unsigned char elementFive = bytePointer[5];
Run Code Online (Sandbox Code Playgroud)
// Assuming you have a void* declared:
void* p;
// and it's initialized to point to a valid object (array of bytes)
// somewhere here...
// ...
// You can convert it to a pointer to unsigned char:
unsigned char* bytes = static_cast<unsigned char*>(p);
// ... and access the bytes using []
unsigned char x = bytes[0];
Run Code Online (Sandbox Code Playgroud)
当然,您使用的字节偏移量必须在void*实际指向的对象大小范围内.
| 归档时间: |
|
| 查看次数: |
400 次 |
| 最近记录: |