Friend, You can declare a pointer and make it point to the constant. Then, you can use the indirection operator to write the new value in the address of the constant.
Ex: --- const int c=100; int *p; c=&p; *p=1000; /*valid in c*/ Now, you can "printf" to print the value of c, which will print 1000. This will work only in c. But, since C++ is clever enough, this syntax is not allowed Friendly, K Adithyan ----- Original Message ---- From: Ray Devore <[EMAIL PROTECTED]> To: [email protected] Sent: Tuesday, 2 January, 2007 10:33:45 PM Subject: Re: [c-prog] Changing value of a constant! --- Gopi Krishna Komanduri <gopikomanduri@ yahoo.com> wrote: > Hi, > I tried to change the value of a constant > variable > whose memory will be in .rdata. But I am unable to > do > it. Could you please go through the following code > and > suggest where I went wrong. <snip code> > Thanks&Regards, > > GopiKrishna Komanduri > Software engineer > NCR Corporation PVT Ltd. > 9849124680 > gopikomanduri@ yahoo.com > gopikrishna. komanduri@ ncr.com > Think of a constant as read-only memory. Where you are going wrong is in trying to change a constant. <rant> There is no such thing as a constant variable. A constant doesn't vary. You can have a constant and you can have a variable, but you can't have a constant that varies. </rant> Ray ____________ _________ _________ _________ _________ __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail. yahoo.com Send instant messages to your online friends http://uk.messenger.yahoo.com
