+ 1

What does static variable means?

20th Feb 2018, 5:47 PM
Deekshith K
Deekshith K - avatar
2 Answers
+ 3
normal variables lose their values when the function they are in is finished, but static variables get to keep their value as long as the program is running. they have the same scope thou
20th Feb 2018, 5:50 PM
Dominique Abou Samah
Dominique Abou Samah - avatar
+ 1
Static variable is a variable which retain its value between the function calls. They are initialized only once and their scope is within the function where they are defined. A static variable inside a function has a lifespan as long as  program runs. It won't be allocated every time  function is called and deallocated when  function returns. http://hckerspeaks.blogspot.in/2017/12/c-interview-question.html
21st Feb 2018, 2:54 AM
Harsh Kumar
Harsh Kumar - avatar