google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Pointers and void pointer and precedence of & and * operators in pointers.

Sunday, March 30, 2014

Pointers and void pointer and precedence of & and * operators in pointers.

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


No comments:

Post a Comment

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...