What is the use of extern keyword in c ?
hiiii CEan
there is compilation error in first program here even out is a global variable but it is not for main
and in second program out is also declare globally but out put is 100 because of extern so can any one explain me how extern work in this program.
main()
{
printf("%d", out);
}
int out=100;
Answer:
Compiler error: undefined symbol out in function main.
and
main()
{
extern out;
printf("%d", out);
}
int out=100;
Answer:
100
there is compilation error in first program here even out is a global variable but it is not for main
and in second program out is also declare globally but out put is 100 because of extern so can any one explain me how extern work in this program.
main()
{
printf("%d", out);
}
int out=100;
Answer:
Compiler error: undefined symbol out in function main.
and
main()
{
extern out;
printf("%d", out);
}
int out=100;
Answer:
100
0