I am currently learning pointers in C. I feel confused about the initialization of a pointer. I might be asking silly questions, but I just want to make sure I understand and learn things right.
So, to initialize a pointer:
int a = 3;
int *pointer = &a;
*pointer = 10;
OR
int a = 3;
int *pointer;
pointer = &a;
*pointer = 10;
So far, I knew that " * " declares a pointer type.
*pointer is the value of whatever value in the address that the pointer points to.
& is the memory address of something.
I can understand 'pointer = &a' in the second case.
But, why do we set *pointer = &a in the first case above since *pointer represents the value in that address?
Why do we make the value in that pointer equals to the address of the variable in the first case when initializing the pointer?