ANSI C support different 3 types of data types.
- Primary data types
- int, (short,long,signed,unsigned)
- char, (signed,unsigned)
- float, (float,double,long double)
- void
- Derived data types
- arrays
- strings
- structures
- User-Defined data type
Storage class and Scope
- auto
- All local variables are auto.
- Scope is limited to withing that funcation
- static
- Variable retains its value even after funcation get exit
- it get initialized by zero always
- This variable is only visable in that file/translation unit
- extern
- this variable is declared by someone else in another file or later in this file
- extern int a; -> this will not add any new memory in system
- register
- Ask compiler to store this register in any CPU register cache instead of memory because of frequent read/write of this variable
Declaring Variable as Constant (constant is a qualifier)
const int class_size = 40;
After this value of class_size can not be changed
Declaring Variable as volatile (volatile is a qualifier)
volatile int class;
This tells the compiler that, value of class can be changed anytime by external sources (from outside the program)
class can be updated even class is not in left side of any assignment in that program.
No comments:
Post a Comment