how can we Declare a variable in c without defining it.



how can we Declare a variable in c without defining it...

Answer / manoj

By using EXTRN.
Example:
File 1:

int GlobalVariable; // implicit definition
void SomeFunction(); // function prototype
(declaration)

int main() {
GlobalVariable = 1;
SomeFunction();
return 0;
}

File 2:

extern int GlobalVariable; // explicit declaration

void SomeFunction() { // function header (definition)
++GlobalVariable;
}

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More C Interview Questions

void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

3 Answers   ME, pspl,


What is the argument of a function in c?

0 Answers  


Write a program to print prime nums from 1-20 using c programing?

13 Answers   IBM,


f1() { f(3);} f(int t) { switch(t); { case 2: c=3; case 3: c=4; case 4: c=5; case 5: c=6; default: c=0;} value of c?

5 Answers   Geometric Software,


Reverse a string word by word??

9 Answers  


if function is declared as static in one source file, if I would like to use the same function in some other source file...is it possible....how ?

2 Answers   NetApp,


What is difference between the following 2 lines…. int temp = (int)(0x00); int temp = (0x00int);

3 Answers   Bosch,


we have a 3litres jug and a 5 litres jug and no measures on them. using these two jugs how can we measure 4 litres of water?

2 Answers   Convergys,


main() { int i=5; printf("%d%d%d%d",i++,i--,i); }

10 Answers  


What is function pointer and where we will use it

2 Answers   Infosys, NetApp,


hello everybody can we change a the adress of a variabl i mean can i put for exemple for a int *p: &p=6 ?????????

1 Answers  


What does typeof return in c?

0 Answers  


Categories