The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
static int st;
Let's workout a program to demonstrate static storage class in C.
#include <stdio.h> //function declaration void subfun(); int main() { subfun(); subfun(); subfun(); return 0; } //function definition void subfun() { static int st = 1; //static variable declaration printf("\nst = %d ", st); st++; }
The program illustrates that, when the function is called, the static variable inside a function is initialized to 1 and retains the incremented value for the upcoming function calls.
Keyword | static |
Storage Type | Memory |
Scope | Block Scope |
Life Time | Static life time |
Visibility | Local/Global |
Default Value | 0 |
Default Storage Class | No |
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019