#include
using namespace std;
int main() {
// 分配10个字节的内存
char* memory = new char[10];
// 使用指针来设置内存的值
unsigned char values[] = {0x00, 0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99};
// 从源头指向的内存块拷贝固定字节数的数据到目标指向的内存块.
memcpy(memory, values, 10);
// 输出已设置的值
for (int i = 0; i < 10; ++i) {
cout << hex << static_cast<int>(reinterpret_cast<unsigned char*>(memory)[i]) << " ";
}
// 释放分配的内存
delete[] memory;
return 0;
}