[Ilugc] Ansi C and 'const' modifier
- From: sridharinfinity@xxxxxxxxx (Sridhar R)
- Date: Wed Aug 11 16:56:04 2004
Anand Kumar Saha <anand.kumar@xxxxxxxxxx> wrote:
| This program
|
| const int a=10;
| a=20;
what happens when you run this program ? does it run properly
or give you a core ?
It runs cleanly.
Okay, the doubt is now cleared. From K&R ...
<quote>
The result is implementation-defined if an attempt is made to change a const.
</quote>
That makes sense for gcc to fire warning instead of error (a=20).
--
Sridhar -
http://cs.annauniv.edu/~rsridhar
Blog:
http://www.livejournal.com/users/sridharinfinity
Other related posts: