@divya: u r rite.. that * should not be there -------------------------------------------------- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14
On Sun, Jun 13, 2010 at 11:07 AM, divya jain <sweetdivya....@gmail.com>wrote: > ptr is a pointer naaa...then why ptr-p=*(&(arr+1)-&arr) ??? > why not &(arr+1)-&arr ?? > i knw m wrong somewhr...plz correct me > > > On 13 June 2010 07:57, Mahesh_JNU <mahesh.jnumc...@gmail.com> wrote: > >> agreed ......... >> >> >> On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar <aryansmit3...@gmail.com>wrote: >> >>> 111 >>> 222 >>> 333 >>> 344 >>> ptr++ ->u do posst increment >>> hence it goes to 1 >>> ptr-p=*(&(arr+1)-&arr)=1 >>> llrly for other cases >>> when u do *ptr++ due to operator precedence ptr++ is done and then >>> dereferenced. >>> hence u get 222 >>> next *++ptr >>> the ptr is incremented after dereferencing hence u get 333 >>> next ++*ptr here the value t ptr s incrementas it is treated as++(*ptr) >>> hence u get 3 but others refer to location hence 44 >>> >>> >>> On Sat, Jun 12, 2010 at 9:21 PM, divya <sweetdivya....@gmail.com> wrote: >>> >>>> #include<stdio.h> >>>> int main() >>>> { >>>> static int arr[]={0,1,2,3,4}; >>>> int *p[]={arr,arr+1,arr+2,arr+3,arr+4}; >>>> int **ptr=p; >>>> ptr++; >>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr); >>>> *ptr++; >>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr); >>>> *++ptr; >>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr); >>>> ++*ptr; >>>> printf("%d %d %d\n",ptr-p,*ptr-arr,**ptr); >>>> return 0; >>>> } >>>> wat shd b the o/p n why... >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to algoge...@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >>>> . >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>>> >>> >>> >>> -- >>> yezhu malai vaasa venkataramana Govinda Govinda >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algoge...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> >> >> -- >> Mahesh Giri >> MCA Final Sem >> JNU, New Delhi >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.