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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

List some of the dynamic data structures in C?

998


Write a program to reverse a linked list in c.

845


By using C language input a date into it and if it is right?

796


What is a null string in c?

791


What is a static variable in c?

861


Is main is user defined function?

846


Is it fine to write void main () or main () in c?

734


Is it acceptable to declare/define a variable in a c header?

865


How can variables be characterized?

1906


What is meant by type casting?

812


How can a number be converted to a string?

893


List the difference between a 'copy constructor' and a 'assignment operator' in C?

844


Do you know the purpose of 'register' keyword?

811


What is the difference between mpi and openmp?

975


Write programs for String Reversal & Palindrome check

784