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 Post>By undefined behavior, do you mean that sometimes it can be changed and sometimes cannot be?
By undefined behavior I mean the C standard makes no guarantees at all about what might happen when your program runs. It's completely unpredictable, even on different runs of the same build. Worse yet, …
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.