Is there any difference between following declarations?
1 :
extern int fun();
2 :
int fun();
[A].
Both are identical
[B].
No difference, except extern int fun(); is probably in another file
[C].
int fun(); is overrided with extern int fun();
[D].
None of these
Answer: Option E
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.
I don't understand the extern. please tell me what is extern.
Pradeep Bhupathi said:
(Wed, Aug 25, 2010 02:13:24 PM)
Extern is a keyword which is used to define any variable or function in externally.
Ashwini said:
(Sat, Sep 25, 2010 05:10:45 AM)
What is global function?
Nagarjuna said:
(Sun, Oct 3, 2010 01:49:48 PM)
How can we declare functions with extern keyword and how can we access that function ?
Rishikumar said:
(Wed, Oct 13, 2010 11:06:17 AM)
How can we declare functions with extern keyword and how can we access that function ?
Ganesh said:
(Sat, Jan 8, 2011 01:12:13 AM)
Extern keyword not understand, please explain.
Smsirajmuneer said:
(Mon, Jan 17, 2011 11:05:24 PM)
'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:
(Mon, Jan 17, 2011 11:12:38 PM)
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:
(Sat, Feb 5, 2011 01:13:21 AM)
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:
(Sat, Mar 5, 2011 09:09:47 AM)
While using extern keyword, memory is allocated to variable or not?
"Declaring a variable as extern will result in your program not reserving any memory for the variable in the scope that it was declared."
Ganesh said:
(Tue, Mar 15, 2011 09:35:49 AM)
Hi sir you said extern is globally declared where as int fun you said localy declared so how you can so it is not different.
Hasi said:
(Thu, Jul 7, 2011 08:59:55 PM)
Global function is nothing but the variables which are used for overall program. Where as local variables are used in specific function or a specific part of the program.
Prakash said:
(Wed, Sep 7, 2011 05:35:15 PM)
Then 'extern' keyword not understand, please explain.
Sanket V Garg said:
(Thu, Sep 22, 2011 12:15:59 AM)
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?
Manas said:
(Mon, Oct 17, 2011 08:34:12 PM)
The extern keyword means "declare without defining". In other words, it is a way to explicitly declare a variable, or to force a declaration without a definition. It is also possible to explicitly define a variable, i.e. to force a definition. It is done by assigning an initialization value to a variable. If neither the extern keyword nor an initialization value are present, the statement can be either a declaration or a definition. It is up to the compiler to analyse the modules of the program and decide.
Venkatramulu said:
(Sat, Jan 7, 2012 07:48:52 PM)
I didn't got suitable answer for "extern" keyword can any one explain with example? please ?