Answers for "storage class"

0

storage class

The storage for variables with global or namespace scope is allocated for the entire 
duration of the program. This is known as static storage, 
and it contrasts with the storage for local variables (those declared within a block). 
These use what is known as automatic storage. The storage for local variables is only available 
during the block in which they are declared; after that, 
that same storage may be used for a local variable of some other function, or used otherwise.

But there is another substantial difference between variables with static storage and variables with automatic storage:
- Variables with static storage (such as global variables) that are not explicitly initialized are 
automatically initialized to zeroes.
- Variables with automatic storage (such as local variables) that are not explicitly initialized 
are left uninitialized, and thus have an undetermined value.
Posted by: Guest on May-29-2021
0

Static Storage class in C

#include<stdio.h>
 static int out;
 //global static variable implicitly initialized to 0
 void main(){
 static int in = 10;//local static variable explicitly ini to 10
 printf("global: %d, local: %d", out, in);
  }
Posted by: Rohan Rai on February-08-2022

Browse Popular Code Answers by Language