I saw in the site with link below that in the ANSI C standard there is the extern keyword, but I have never seen it being used in practice. What exactly does she do?
I saw in the site with link below that in the ANSI C standard there is the extern keyword, but I have never seen it being used in practice. What exactly does she do?
Man, after searching I understand that extern is to indicate that a variable has already been defined in another part of the program as a whole. For example, if you divide a giant code into 2 parts. You should tell the compiler that you are using these variables in one block (file 2) but they have been initialized in another block (code 1).
For example:
Code 1:
int count;
float sum;
int main(void)
{
...
return 0;
}
Code 2:
extern int count;
extern float sum;
int RetornaCount(void)
{
return count;
}
Here is a link that explains it better than I did: link
I hope I have helped.