我如何制作这样的作品呢?
void *memory = malloc(1000); //allocate a pool of memory *(memory+10) = 1; //set an integer value at byte 10 int i = *(memory+10); //read an integer value from the 10th byte
解决方法
简单示例:将内存视为unsigned char数组
void *memory = malloc(1000); //allocate a pool of memory uint8_t *ptr = memory+10; *ptr = 1 //set an integer value at byte 10 uint8_t i = *ptr; //read an integer value from the 10th byte
您也可以使用整数,但是您必须注意一次设置的字节数.