I am currently in the learning process of pointers in C. I came to know that, a pointer is a variable which stores the address of another variable. So when I did something like,
#include <stdio.h>
int main()
{
int x = 10;
int *ptr;
ptr = &x;
printf("%d" ,ptr);
The above gave me the address in integer values.
My question is, the pointer variable ptr stores address of variable of type int.
As per my PC, int is taking 4 bytes which is 32 bits. As per my understanding each bit has a separate memory address.
So what is the address pointer will point to? Will it point to the first bits memory address or something else? Please let me know.
Please correct me if my understanding is wrong.
A memory address is the location of one byte. A 32-bit location is the location on a four byte boundary.
So memory address 0x0000 is equal to the first 32-bit memory location. Address 0x0004 would be equal to the next four-byte boundary or, in other words, the next 32-bit location.
Then that just leaves the issue of big-endian and little-endian.