What does extern mean in a function declaration?
Answers were Sorted based on User's Feedback
extern is significant only with data declarations. In
function declarations, it can be used as a stylistic hint
to indicate that the function's definition is probably in
another source file, but there is no formal difference
between
extern int f();
and
int f();
| Is This Answer Correct ? | 91 Yes | 14 No |
Answer / poornima
extern is a keyword that is prefixed in function
declaration. It means tht function definition is in source
file.
for eg.
source file contains int sum(int x,int y) definition part.
To make use of this function in file by simply declare as
extern int sum(int ,int); is a good practice.
But to compiler happy extern sum(); is enough.
| Is This Answer Correct ? | 34 Yes | 16 No |
Answer / zxg
(from MSDN)
Functions declared as extern are visible throughout all source files in the program (unless you later redeclare such a function as static). Any function can call an extern function.
Function declarations that omit the storage-class specifier are extern by default.
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / aravind
Extern is nothing but a memory storage type.If we declare extern before the function than the variable can be accessed by that function not only locally but externally too.
extern int a=4
Int fun (int x)
{
x=a;
print gives a=4
| Is This Answer Correct ? | 8 Yes | 19 No |
What is use of #include in c?
what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }
What is a spanning Tree?
Explain how do you use a pointer to a function?
Why is c called "mother" language?
When should we use pointers in a c program?
what is the use of #pragma pack, wer it is used?
how can i calculate mean,median,mode by using c program
write a c/c++ programthat connects to a MYSQL server and checks if the INNoDB plug in is installed on it.If so your program should print the total number of disk writes by MYSQL.
What is the purpose of & in scanf?
where does malloc() function get the memory?
Print all numbers which has a certain digit in a certain position eg: number=45687 1 number=4 2 number=5 etc