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 1 of 6.

Shobhit said:   2 decades ago
I don't understand the extern. please tell me what is extern.

Pradeep bhupathi said:   1 decade ago
Extern is a keyword which is used to define any variable or function in externally.

Ashwini said:   1 decade ago
What is global function?

Nagarjuna said:   1 decade ago
How can we declare functions with extern keyword and how can we access that function ?

Rishikumar said:   1 decade ago
How can we declare functions with extern keyword and how can we access that function ?

Ganesh said:   1 decade ago
Extern keyword not understand, please explain.

Smsirajmuneer said:   1 decade ago
'extern' is similar to the gloabal declaration we can access any where in the program module, similar to accessing the functions in .dll files from various .exe files.

Sirajmuneer said:   1 decade ago
extern refers to suppose inside a local variable in main() we can access outside this variable its called extern and the same as fun() can be accessed
syntax:
main()
{
extern int s; //external declaration
}
fun1()
{
extern int s; //external declaration
}

int y; //definition

Pankaj said:   1 decade ago
The extern int fun(); is nothing but it can be declared globlly means out side the function.

But int fun(); can be declared in local means in the function only.

Nancy said:   1 decade ago
While using extern keyword, memory is allocated to variable or not?


Post your comments here:

Your comments will be displayed after verification.