I'm a C beginner. Having trouble understanding whats happening with this code:
#include <stdio.h>
#include <stdint.h>
int main(void)
{
uint64_t num = 99999;
uint64_t *num_ptr = #
uint8_t first_byte = ((uint8_t *)num_ptr)[0];
printf("%hhu", first_byte);
return 0;
}
This prints 159.
I'm looking at uint8_t first_byte = ((uint8_t *)num_ptr)[0];
I'm trying to understand it this way: the uint64_t pointer num_ptr is first cast as a uint8_t pointer, then we index into it with the square brackets to get the first byte. Is this a correct explanation? If so is it possible to index into pointers to get their partial contents without dereferencing?