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

How can I sort a linked list?

0 Answers  


Tell me when is a void pointer used?

0 Answers  


What does a function declared as pascal do differently?

0 Answers  


the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters

2 Answers  


what is a function method?give example?

0 Answers  






What is this infamous null pointer, anyway?

0 Answers  


program for validity of triangle from 3 side

7 Answers  


what does exit() do?

3 Answers   Cadence,


How do you define a function?

0 Answers  


Is there a way to jump out of a function or functions?

0 Answers  


How to delete a node from linked list w/o using collectons?

0 Answers   Zycus Infotech,


What the advantages of using Unions?

0 Answers   TISL,


Categories