If I cast a pointer from int32_t to int8_t, why does the pointer’s value not change? I expected the resulting value to change from a 32-bit address to an 8-bit address.
When experimenting with the code below, it does not change. Why?
#include <stdio.h>
#include <stdint.h>
int main()
{
int32_t * first = (int32_t *) 0xFFFFFFFF;
int8_t * second = (int8_t *) first;
printf("Gives: %p n", first);
printf("Gives: %p n", second);
return 0;
}
New contributor
evstack is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.