Pointers
Definition:- A pointer is a variable that stores the memory address of another another variable.
void pointer :-( it can contain address of any data type )
syntax:- void *pointer_name;
example:- void *v_ptr;
A void pointer does not have any data-type associated it with and can contain the address of any type of variable.
example:- void v_ptr;
char ch;
int i;
float fvar;
v_ptr= &ch;
v_ptr= &i;
v_ptr =&fvar;
Precedence of & and * operator:-
Both are unary operators and have precedence equal to other unary operators.
Their associativity is from right to left.
example:- int n=10,++*ptr;
ptr = &n;
ptr = 1024
++ *ptr = ++(1024)
= ++(10)
= 11
*ptr++ = (*1024)++
=10 ++
=10
* ++ptr = *(++1024)
= *(1026)
= data at 1026
Definition:- A pointer is a variable that stores the memory address of another another variable.
void pointer :-( it can contain address of any data type )
syntax:- void *pointer_name;
example:- void *v_ptr;
A void pointer does not have any data-type associated it with and can contain the address of any type of variable.
example:- void v_ptr;
char ch;
int i;
float fvar;
v_ptr= &ch;
v_ptr= &i;
v_ptr =&fvar;
Precedence of & and * operator:-
Both are unary operators and have precedence equal to other unary operators.
Their associativity is from right to left.
example:- int n=10,++*ptr;
ptr = &n;
ptr = 1024
++ *ptr = ++(1024)
= ++(10)
= 11
*ptr++ = (*1024)++
=10 ++
=10
* ++ptr = *(++1024)
= *(1026)
= data at 1026