@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
bt the ans that sharad gave is ryt..
acc to me 1st row n 1st col of o/p shd b 2 (if size of int is 2) bt it is
1...
On 13 June 2010 12:10, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
@divya: u r rite.. that * should not be there
--
Rohit
actually when you subtract two pointers ... its get divided by the size of
the variable type its point two...
for example.. if you do .. p+1... where let say p is 200 and points to an
int type variable then p+1 is 202...(assuming int is of size 2)
so (p+1)-p..i.e 202-200 is 1 and not 2
On
@jalaj: exactly...
so you(@divya) are right. Sharad's ans was right but logic wasn't.
--
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 2:35
oh yes..
wen ll i stop making this stupid mistakes :(
On 13 June 2010 15:03, Rohit Saraf rohit.kumar.sa...@gmail.com wrote:
@jalaj: exactly...
so you(@divya) are right. Sharad's ans was right but logic wasn't.
--
Rohit Saraf
Second Year
#includestdio.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
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
agreed .
On Sun, Jun 13, 2010 at 7:48 AM, sharad kumar aryansmit3...@gmail.comwrote:
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.
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.comwrote:
111
222