I learned C language and I have some questions.
If the best way to find address of the beginning of a memory area is to use pointers?
For example in a few steps
1) I have variable int a = 1;
2) I declare pointer to variable a: int *pointer_a;
3) I assign variable a to pointer: pointer_a = a;
4) Now, I want to print address in memory area:
printf("Adress variable a= %p", &pointer_a);
Am I doing it right?
pointer_a should hold memory address of variable
a, that's what pointers do. as far as pointers are concern
& is the
address of operator.
pointer_a = &a;
and then you can.
printf("Address variable a = %p", &pointer_a);
you can still directly
printf("Address variable a = %p", &a);