Why use constants in programming?

Posted by Adam N on Stack Overflow See other posts from Stack Overflow or by Adam N
Published on 2010-06-01T21:47:47Z Indexed on 2010/06/01 21:53 UTC
Read the original article Hit count: 209

Filed under:
|
|
|
|

I've just been going back over a bit of C studying using Ivor Horton's Beginning C book. I got to the bit about declaring constants which seems to get mixed up with variables in the same sentence.

Just to clarify, what is the difference in specifying constants and variables in C, and really, when do you need to use a constant instead of a variable? I know folks say to use a constant when the information doesn't change during program execution but I can't really think of a time when a variable couldn't be used instead.

Thanks

© Stack Overflow or respective owner

Related posts about c

    Related posts about variable