C – Storage Class specifiers Extern

  • The extern keyword is used before a variable to inform the compiler that this variable is declared somewhere else.
  • The extern declaration does not allocate storage for variables.
  • Used to resolve the scope of global symbol
  • Eg : Example Using extern in same file

Extern Variable Initializer

Extern as global variable initializer

  • The extern keyword variable can be initialize when its global

 

Example : External variable always initialize (Zero) ‘0’

 

Example : variable initialize in  global variable

 

Example :

 

 

Example : variable initialize in  global variable

 

Example : variable initialize in  global variable

 

 

Example : Error while running Linker

 

Extern as local variable initializer

  • The extern keyword variable can not be initialize when its local or inside the function. (an initializer is not allowed on a local declaration of an extern variable)

EXample : an initializer is not allowed on a local declaration of an extern variable

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

if you have any queries call us +918300026060 or WhatsApp Dismiss

0

Your Cart

%d bloggers like this: