R
rahul8143
hello,
Consider following code1
int main()
{
int i=100;
int &k=i;
k++;
cout<<i<<endl;
int *p=&i;
(*p)++;
cout<<*p<<endl;
i++;
cout<<i<<endl;
RETURN 0;
}
Now to incremanet i value i have to use (*p)++ instead of *p++.
now consider code2
int main()
{
int a[]={11,22,33,44};
int *p=a;
cout<<++*p++<<endl; //12
cout<<(*p)++<<endl; //22
return 0;
}
why in above code why (*p)++ gives 22 instead 23? Also how
++*p++ gets evaluated?
regards,
rahul.
Consider following code1
int main()
{
int i=100;
int &k=i;
k++;
cout<<i<<endl;
int *p=&i;
(*p)++;
cout<<*p<<endl;
i++;
cout<<i<<endl;
RETURN 0;
}
Now to incremanet i value i have to use (*p)++ instead of *p++.
now consider code2
int main()
{
int a[]={11,22,33,44};
int *p=a;
cout<<++*p++<<endl; //12
cout<<(*p)++<<endl; //22
return 0;
}
why in above code why (*p)++ gives 22 instead 23? Also how
++*p++ gets evaluated?
regards,
rahul.