I use two variables in which memory is allocated dynamically, and I print the memory locations, but they are not consecutive. Why?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int *a = malloc(sizeof(int));
int *b = malloc(sizeof(int));
printf("\n a=%p \t b=%p \n",a,b);
}
The answers I get (in Linux) are
1st time:
a=0x20a0010 b=0x20a0030
2nd time:
a=0x657010 b=0x657030
3rd time:
a=0x139e010 b=0x139e030
Why is the exact difference between the memory locations of a and b variables the way it is in the 1st, 2nd and 3rd times?
Is this related to paging memory?
My processor is 64 bit.