Hi Sourav; hope you're fine. "will not be able"... This is wrong. In C, `const` is a promise by the programmer not to change, not enforced by the compiler/runtime.
– too honest for this siteAug 04 '15 at 13:57
You can cast away the const, still using the same object (yes, that should generate a warning, but, hey warning is better than error ...;-)
– too honest for this siteAug 04 '15 at 13:59
@Olaf ahh, that way, it's _bypassed_. At least, for the first time, without the cast, we'll get to know, we should not have changed that....... :-)
– Sourav GhoshAug 04 '15 at 14:01
2
Yeah, I'm a destructive bastard;-) - one reason I have to be careful writing code, if I'm not, it breaks when I test already. Other people manage to surf around their bugs (unintended). FYI: In other languages, like Python, you can make objects true read-only using e.g. properties. Any access will result in runtime exception. In C, there is no guarantee about this, just UB.
– too honest for this siteAug 04 '15 at 14:05
@MartinJames maybe the developer would, who doesn't want the maintainer to _alter_ the input parameter, for _some_ reason. :-)
– Sourav GhoshAug 04 '15 at 15:01
@SouravGhosh sure, yes. It's just that I'm struggling to think of an example here I may want to do that:)
– Martin JamesAug 04 '15 at 15:19