Presentation is loading. Please wait.

Presentation is loading. Please wait.

C Programming Lecture-17 Storage Classes

Similar presentations


Presentation on theme: "C Programming Lecture-17 Storage Classes"— Presentation transcript:

1 C Programming Lecture-17 Storage Classes
$p!derLabWeb C Programming Lecture-17 Storage Classes

2 What is Storage Classes?
Storage classes defines the scope (visibility) and life time of variables and/or functions within a c program. The storage class tells about the default values the variables if not initialized. And also where the memory of the variable is located.

3 Types of Storage Classes
There are four types of storage classes :- auto (Automatic storage class) register (Register storage class) static (Static storage class) extern (External storage class)

4 auto Storage Class Auto is the default storage class for all local variables. The memory of variables defined auto is located in the RAM. If the variable of auto storage class is not initialized than it will take some garbage value. Eg. auto int a = 4; auto float b = 6.9;

5 register Storage Class
The variables of register storage class are stored in the register. Only those variables are declared by register storage class which are required frequently and quickly. Eg. register int a = 0; register char ch = ‘h’;

6 static Storage Class The variables which defined by the static storage class have the scope in the whole program. We can’t create the variables of static storage class of same name twice. The default values for variables of static storage class is 0, ‘\0’ , NULL. Eg. static int a = 45;

7 extern Storage Class Extern is used to give a reference of a global variable that is visible to all the program files. When you use ‘extern’ the variable cannot be initialized as all it does is point the variable name at a storage location that has been previously defined. Eg. extern int a;

8 Thank you!


Download ppt "C Programming Lecture-17 Storage Classes"

Similar presentations


Ads by Google