C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 4)
4.
Is there any difference between following declarations?
1 : extern int fun();
2 : int fun();
Both are identical
No difference, except extern int fun(); is probably in another file
int fun(); is overrided with extern int fun();
None of these
Answer: Option
Explanation:

extern int fun(); declaration in C is to indicate the existence of a global function and it is defined externally to the current module or in another file.

int fun(); declaration in C is to indicate the existence of a function inside the current module or in the same file.

Discussion:
56 comments Page 6 of 6.

Sm das said:   1 decade ago
It is a keyword which functioning same as global and local variables.

Vijay said:   1 decade ago
Why we use extern function in C?

Subhasish said:   1 decade ago
Could anybody please tell me what is the scope for extern, I mean; say we have two files in two different directories I want to use one variable/function of file1 in file2 but those 2 are in diff. Directories. So can I access the elements of file1 in file2 using extern?

Pradeep said:   1 decade ago
Does storage classes can be used with data types and keywords.

Preethe said:   1 decade ago
What is meant by global variables? please explain.

Mumukshu said:   1 decade ago
The answer is incorrect. In C language, by default all function declarations are extern as C does not support local functions. Extern func(); and func(); are the same.


Post your comments here:

Your comments will be displayed after verification.