For example
printf("%u",&a);
gives me output
65524
which is a 16 bit address.
For example
printf("%u",&a);
gives me output
65524
which is a 16 bit address.
Because you used wrong format specifier which invokes undefined behavior.
To print a pointer, you should use %p
format specifier and cast the argument to void*
. Something like
printf("%p",(void *)&a);
will do the job.
That said, you should look into the concepts of virtual memory the first thing.
You can also simply answer your assumption about address size by checking the size of any pointer instead of a test variable's address:
printf("%zu\n", sizeof(int*));
printf("%zu\n", sizeof(float*));
Assuming that a byte in all systems equals eight bit, you can see about size of address.
Please see this SO post
To find the highest possible address for (most of) the currently common systems do this:
#include <stdint.h>
#include <stdio.h>
int main(void)
{
uintptr_t uip = (uintptr_t) -1;
void * vp = (void*) uip;
printf("%p\n", vp);
}