answersLogoWhite

0


Best Answer

The "extern" declaration in C is to indicate the existence of, and the type of, a global variable or function. A global variable, or a global function, is one that is available to all C modules (a single C module is typically a single .c file). An extern is something that is defined externally to the current module. In many cases, you can leave off the extern qualifier and not notice any difference because the linker can collapse multiple definitions to one. But the intent is then unclear in the code, and the code is error prone in case of typos. It is much clearer to define the global in one place, and then declare extern references to it in all the other places. When refering to globals provided by a library, especially a shared library, this is even more important in order to ensure you are talking about the correct, common instance of the variable. Declaring a variable as extern will result in your program not reserving any memory for the variable in the scope that it was declared. For instance (as example) if a program's source code declared the variable var as a global volatile int in foo.c, to properly use it in bar.c you would declare it as extern volatile int var. It is also not uncommon to find function prototypes declared as extern.

A good C manual will certainly answer this more completely.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

In C and C++, extern is a declaration of a variable or function, said declaration including the fact that the definition of that variable or function will occur in a different compilation unit, linking provided by the link editor or binder.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

An external variable is a variable defined outside any function block. They are permanent, thus retain their value regardless of the functions.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

You can put it before a variable-declaration; it means: this variable is defined somewhere else. You can use it before a function-declaration too, but it doesn't change anything.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is external variable in c language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are c storage classes?

storage classes determines the part of memory where storage is allocated for an object. a scope specifies the part of the program which a variable name is visible, that is accessibility of the variable by its name. in c language there are four storage classes automatic, external, register, static.


What is a variable in C language?

variable which is used to specify the values and also we can that values through the variable name


What is puts in c language?

printf("%s",variable);


How you declare a variable in c language?

you have to give a statement in the following syntax datatype variable;


What is a constant variables in c language?

It are a variable you add modifer 'const' to. It means these variable mustn't be modified.


What is the variable in c language program?

A variable is the name for a place in the computer's memory where you store some data.


What is count in c language?

count is a function that counts the variable name.


Is “C language” case sensitive programminIs “C language” case sensitive programming language If yes why and if no whyg language If yes why and if no why?

C is case sensitive, which means that, for example, $var and $VAR are not the same variable.


In c language which variable is not valid?

eg: 7x 9# répa 'quote'


What is the definition of the term C static?

The term C static is a variable within computer programming in particular C Language. When set static the variable inside a function keeps its value between invocations.


Int a is literal in C language or not?

int a; -- variable definition"int a" -- string literal


Why c in and c out used in c?

In the programming language C++, cin is used to input the variable and cout is used to print a certain message or result.