Table of Contents
show
Extern Storage Class
- Identifiers declared in the global scope by default have extern storage class
- We can also access extern variables of one file to another file. But make sure both files are in same folder.
- extern variable cannot be initialized if a declaration statement is written within the block or local scope
- The extern storage class specifier cannot be used in the parameter declaration either in the function declaration or in the function definition
Example
#include<stdio.h>
#include<conio.h>
extern int a=200;
int main()
{
printf("a = %d\n",a);
return 0;
}
Output
C:\TDM-GCC-64>gcc extern.c -o extern
extern.c:3:12: warning: 'a' initialized and declared 'extern'
extern int a=200;
^
C:\TDM-GCC-64>extern
a = 200
Views: 1