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 |
how should functions be apportioned among source files?
What is a pointer in c?
1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop
wat are the two methods for swapping two numbers without using temp variable??
What does %c do in c?
how to generate the length of a string without using len funtion?
How do I get a null pointer in my programs?
In C program, at end of the program we will give as "return 0" and "return 1", what they indicate? Is it mandatory to specify them?
At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.
What are the difference between a free-standing and a hosted environment?
Why is void main used?
char S; char S[6]= " HELLO"; printf("%s ",S[6]); output of the above program ? (0, ASCII 0, I,unpredictable)