When do you use const

Paul Siu paul at tredysvr.Tredydev.Unisys.COM
Sat Feb 2 03:53:26 AEST 1991


In ANSI C, you can define a variable as constant by preceeding it with const.
You can for example define a double variable x that you cannot change by

     const double x;

However, what is the advantage of using const over #define?  Why was the
reason for its addition to ANSI C.

Paul Siu
paul at tredysvr.tredydev.unisys.com



More information about the Comp.lang.c mailing list