I know this is very basic but it is little bit confusing to me.
I\'ve read:
a pointer is nothing more than an address
The token p
is a pointer variable, that points to a variable i
. We can simply call it a pointer.
A declaration:
int* p;
int i;
p = &i;
declares p
as the identifier of an int
type object. This is usually stated more succinctly as 'p is a pointer to i'
. p
can be used to refer int variable i
after expression p = &i
. To access the value of variable i
using pointer p
you can use the dereference operator *
(e.g. *p
). And i = 10;
equivalent to *p = 10;
.
Also, notice in expression p = &i;
to read the address of i
I used &
ampersand operator also called Address of operand
.
A pointer is just a logical address (an identifier by which a variable can be referenced). The C standard does not define what a pointer is internally and how it works internally.
You would like to read: What exactly is a C pointer if not a memory address?
Additionally, read this: to Understand the purpose of pointers.