Saturday 21 October 2017

static varaible

   int i=10;
   static int x = i;===> compile time error


Static variable
Auto variable
 We have to specify the storage class to make a variable static.
It is the default storage class.
If it is not assigned any value then it will give 0 as out put.
If it is not assigned any value then it will give garbage value as output.
It is visible to the block in which it is declared and also in the function where it will passed.
It is visible to the block in which the variable is declared.
It retains its value between different function calls. It holds its last value.
It retains its value till the control remains in the block in which the variable is declared.
Static variable should be compile by compiler first.
Auto variable will compile by the compiler after the static variable.

No comments:

Post a Comment