Pointers Variables
Now you know about address in computer memory, it's time to learn about pointers.
Consider a normal variable as in above example, these variables holds data. But pointer variables or simply pointers are the special types of variable that holds memory address instead of data.
How to declare a pointer?
int *p; OR, int* p;
The statement above defines a pointer variable p. The pointer p holds the memory address. The asterisk is a dereference operator which means pointer to. Here pointer pis a pointer to
int
, that is, it is pointing an integer.
Note: In above statement p is a pointer variable that holds address not
*p
. The *p
is an expression. The content(value) of the memory address pointer p holds is given by expression *p
.
No comments:
Post a Comment