Static Storage Class

Give one real time application where static variables are used.

Questions by shyamkumar1221

Editorial / Best Answer

clickankit4u  

  • Member Since Feb-2009 | Aug 3rd, 2011


Thinks of a situation where you need to do some work just once in a function irrespective of how many times that function is invoked then u can have a static variable which will keep a track of it. eg int main () { static int once = 0; if (!once) { once++; /*code need to be executed once*/ } /*reset of the code*/ }

Showing Answers 1 - 0 of 0 Answers

Thinks of a situation where you need to do some work just once in a function irrespective of how many times that function is invoked then u can have a static variable which will keep a track of it.
eg

int main ()
{
static int once = 0;
if (!once)
{
once++;
/*code need to be executed once*/
}

/*reset of the code*/

}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions