clanguage07@gmail.com

clanguage07@gmail.com

Saturday, September 7, 2013

Pointers to pointers in c programming language


C pointers to pointers: A pointer is pointing to another pointers is called pointers to pointer.

Examples of pointers to pointers in c:

What will be output if you will execute following code?

#include<stdio.h>

int main(){

int s=2,*r=&s,**q=&r,***p=&q;

printf("%d",p[0][0][0]);
return 0;

}

Output: 2

Explanation:

As we know p[i] =*(p+i)

So,

P[0][0][0]=*(p[0][0]+0)=**p[0]=***p

Another rule is: *&i=i

So,

***p=*** (&q) =**q=** (&r) =*r=*(&s) =s=2

No comments:

Post a Comment

GET MORE INFORMATION

http://ads.qadservice.com/t?id=c2168e05-8974-4816-872a-91936ff7379d&size=1024x768&drct=true