extern in c

extern in c is part of External Storage Class. extern keyword is used in c to declare external variable outside the function

Before going to know extern first know the External Storage Class

External Storage Class

External variables are declared outside all functions, yet are available to all functions that care to use them

Example of programme based on extern keyword in c

int x = 21 ; 
main( ) 
{ 
 extern int y ; 
 printf ( "\n%d %d", x, y ) ; 
} 
int y = 31 ;

In the above example extern int y has been initialize outside the function

Leave a Comment