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

Sruthi said:   9 years ago
Is the variable declared as extern similar to the variable declared under main?

Harvansh singh said:   9 years ago
What is the actual meaning of extern keyword? Explain clearly.

Jhansi said:   8 years ago
What is extern? I can't get it.

Harish said:   8 years ago
Extern is a keyword to storage class external.

Whose memory allocation will be done in a data area.
SCOPE of the variable with extern declaration is global. (It's reduce code security levels )

Thanks for your example @Keerthi.

Ranjith said:   8 years ago
What the extern function to do?

But how could you say that there is no difference between the two? Please tell me.

Suraj said:   7 years ago
Thanks for explaining the answer.

Bhargavi said:   7 years ago
Please tell the difference between extern and static, automatic.

Venkatesh said:   8 months ago
@All.

Here is my explanation.
1) extern and global are the same thing but when we use the keyword "extern" is important.
2) extern use only for function and variable and use when you assign an extern then don't assign value it raises an error.
3) The directly say that use on extern is you access the variable or function inside as well as outside file.

Sanket V Garg said:   1 decade ago
If we declare any functions external as well as an internal function in same code then if latter that function is called from anywhere in file the which function will be loaded? how is the issue of function resolved in these scenario? can anyone please explain these to me?

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


Post your comments here:

Your comments will be displayed after verification.