Through my knowledge, I know that by declaring a variable as 'const', its stored in read only memory and at the same time I found that a const variable's value can be changed using pointers. How is it possible?
illuminatus89
0
Newbie Poster
Recommended Answers
Jump to PostDepends...Where are you declaring this const variable? Is it local, on the read/write stack?
Jump to Post>I know that by declaring a variable as 'const', its stored in read only memory
Incorrect. There's no rule that says const qualified objects must be stored in read-only memory.>I found that a const variable's value can be changed using pointers.
Maybe, maybe not. Attempting to modify the …
Jump to PostBy undefined behavior, do you mean that sometimes it can be changed and sometimes cannot be?
By undefined, I think she means not define within the C language so the compiler designer(s) are free to implement it any way they want....ie, don't expect consistent implementation.
All 9 Replies
gerard4143
371
Nearly a Posting Maven
Narue
5,707
Bad Cop
Team Colleague
illuminatus89
0
Newbie Poster
illuminatus89
0
Newbie Poster
gerard4143
371
Nearly a Posting Maven
manojwali
-4
Light Poster
prvnkmr449
-8
Junior Poster
Narue
5,707
Bad Cop
Team Colleague
manojwali
-4
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.