Prashant Dixit said:
(Sun, Jan 30, 2011 03:21:07 AM)
There must be an error in this program because ptr is declared as of constant type and it can not be modified so value of j can not be stored in ptr.
Himanshu said:
(Mon, Feb 21, 2011 10:17:35 AM)
Can't get it. Please explain it in step by step procedure.
Sundar said:
(Fri, Mar 18, 2011 12:15:37 PM)
Output:
In Turbo C (under DOS - 16 bit platform)
i = FFF4 ptr = 10 j = FFF2 ptr = 20
In GCC (under Linux - 32 bit platform)
i = BF93368C ptr = 10 j = BF933688 ptr = 20
I hope this may be help you a bit. Have a nice day guys!
Ajay said:
(Sat, Jul 9, 2011 02:11:26 PM)
const int *ptr = &i;
It declares a pointer which points to integer of constant type.
Pointer is not constant.So we can change it.
Sharath said:
(Thu, Jul 14, 2011 09:50:27 PM)
We can change the value of constant pointer
Sharath said:
(Thu, Jul 14, 2011 10:02:19 PM)
int i=10;
const int *ptr=10; //correct
*ptr=&i; //correct
*ptr=10; //wrong
Siva Pavan said:
(Wed, Sep 14, 2011 10:58:29 PM)
Coming to 2nd printf statement, since in pointers &p represents address,*p represents value then clearly p is declared as pointer preccedding by const keyword so its value is always constant since it is addressed to x(p=&x) the only possible value for p is x value i.e 10.