C/Type Qualifiers

From Wikiversity
< C
Jump to: navigation, search

C Type Qualifiers[edit]

C type qualifiers add special properties to the variables being declared. C provides the following two keywords:

  • const: the const qualifier is used to indicate the variable value can not be changed after its initialization. As an alternative, the #define preprocessor directive can be used to define constant values and these will consume no memory space.
  • volatile: the volatile qualifier indicates that variable values can be changed without the current program's knowledge and so the compiler should not optimize away uses of that variable.

Note: a Standard conforming compiler can ignore these qualifiers; nevertheless, it must issue a message when an attempt is made to alter an object declared as const.


Project: Topic:C
Previous: Data Types and Keywords — C/Type Qualifiers — Next: Storage Classes