struct media{ uint32_t addressOfPtr; };
某處出錯,但我無法看到它。無法將int數組複製到給定結構的結構地址中
printf(" > %x", ((uint8_t*) mediaObject2->addressOfPtr)[i]);
不打印
uint8_t message[SIZE_MAX];
for (i=0;i<SIZE_MAX;i++) {
message[i] = i+1;
printf(" > %x", message[i]);
}
uint8_t *msg_Ptr;
msg_Ptr = malloc(SIZE_MAX*sizeof(uint8_t));
memcpy(msg_Ptr, &message, SIZE_MAX);
printf("\n####################\n");
for (i=0; i < SIZE_MAX; i++) // message fixed at length 10
printf(" > %x", msg_Ptr[i]);
printf("\n");
struct media *mediaObject2;
(mediaObject2->addressOfPtr) = malloc(SIZE_MAX*sizeof(uint8_t));
(mediaObject2->addressOfPtr) = (uint32_t) msg_Ptr;
printf("\n####################\n"); // Last stop
//printf(">>>> %x ", mediaObject2->addressOfPtr);
printf("\n");
for (i=0; i < SIZE_MAX; i++) // message fixed at length 10
printf(" > %x", ((uint8_t*) mediaObject2->addressOfPtr)[i]);
printf("\n");
並且應該在''中使用不同的名稱'SIZE_MAX'。 –
BLUEPIXY
你,是對的。我會。 –