answersLogoWhite

0

Why extern long int var is a declaration?

Updated: 8/17/2019
User Avatar

Wiki User

14y ago

Best Answer

Because it doesn't define the variable. If you want to define it, simply write:

long int var;

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why extern long int var is a declaration?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is external variable in c language?

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.


Store value in variable c plus plus?

#include<iostream> int main() { int var=42; // store the value 42 in a variable named var. return(0); }


Is unsigned int var valid in java?

No. Java uses no unsigned numbers.


What is the prototype of scanf in c programmin?

int scanf(char* format, ...); the format accepts the format specifier string, the elipsis operator accepts the variable list scanf("var type var type ...", &var, &var, ...); example: int num1, num2, num3; scanf("%d %d %d",&num1,&num2,&num3); Is that what you were looking for? Maybe this can help also...


Difference between the definition and declaration of a variable in c?

definition defines the memory area ( allocates the memory ) for the variable and the declaration tells about the signature of the variable ( type and size to be considered). definition occures once through the program( memory is allocated once ), but the declaration can occur many times.OR For a variable, the definition is the statement that actually allocates memory. For example, the statement:long int var;is a definition. On the other hand, an extern reference to the same variable:extern long int var;is a declaration, since this statement doesn't cause any memory to be allocated. Here's another example of a declaration:typedef MyType short;Second AnswerDeclaration can come only once and definition can come many times in the program.Let's take an example,Line 1: #includeLine 2:Line 3: void main()Line 4: {Line 5: int x; //declarationLine 6:Line 7: x=10; //definitionLine 8: }In the above program, on the line 5 what appears is declaration and on line 7 the definition is there.Now if we declare the variable x again in the program we will get the error saying that the variable is already declared.Whereas if we assign some new value to variable x, say 20i.e.x=20;this is totally fine and we can assign any number of values in the same program. This means that the declaration is only one throughout the program but definitions can be many.


Explanation of for loop?

for is the most common loop for mathematical calculations. It looks like following for (type var1 = inticialization; var (condition to continue); var(+ operation)) for instance for (int i = 0; i < 10; i++) { cout


What is value parameters in arrays concept on a C?

An array in C is basically a pointer to a sequence of successive elements of the array type; for example this array char var[4]; is an array of four characters. In this case "var" will be a pointer to character, or char*, on a system with a 32-bit memory space (all PCs from the 386 up to the year 2008, newer may have a larger memory space) "var" itself will be 32 bits in size. The first array value is the char-sized (assume 8 bits) memory location where "var" is pointing to; this is "*var" or "var[0]". The second element of the array is "*(var+1*sizeof(char))" or "var[1]", the third "*(var+2*sizeof(char))" or "var[2]" and the fourth is "*(var+3*sizeof(char))" or "var[3]". because C has no boundary checking trying to write of read "var[4]" (the fifth char) will not rise a violation, however you never requested this memory space! The compiler may very well have decided to put another variable in this place, which will thus be overwritten when writing to it. This is why you should ALWAYS assure that there is no way you could ever write outside of the reserved memory space! To sum up: int var[SIZE]; will reserve SIZE slots of "int"-sized memory and a pointer to the first of those ints. "var" is that pointer, while "var[0]" is the first int. Assure to never write (or read) to var[X] where X is EQUAL or greater than SIZE (or X less than zero).


What is the definition for call by value in c language?

A function is called within a function either called by value or called by reference.When a function is called by passing the values of one or more variables,then the value is copied to a new var of the function's own var of its scope.Ex:void main(){...........c=fun(a,b);...}fun(int c,int d){ int t;t=c+d;return(t);}


What is the three major parts of a pascal program?

-var,const,uses declaration part could start with uses in case of a declaration for a libr ex. (uses crt) var,const refers to those used in the main probram -functions,procedures declaration part declaration of the function/procedure + content ex. (function one(x:integer):integer; var y:integer; begin ...... one=....(integer expresion for return value); ...... end;) the procedures don't have any return value (:integer) -main program begin ........ end.


How do you pass an array to a function in C programming?

The declaration of an array of 3 int pointers will be: int *p[3]; The declaration of a function that receive an array of int pointers will be: int my_func(int **p); or int my_func(int *p[]); and you can pass it to other function simply by passing p.


Can you use extern and static together?

Storage classes are used to indicate duration and scope of a variable or identifier. Duration indicates the life span of a variable. Scope indicates the visibility of the variable. The static storage class is used to declare an identifier that is a local variable either to a function or a file and that exists and retains its value after control passes from where it was declared. This storage class has a duration that is permanent. A variable declared of this class retains its value from one call of the function to the next. The scope is local. A variable is known only by the function it is declared within or if declared globally in a file, it is known or seen only by the functions within that file. This storage class guarantees that declaration of the variable also initializes the variable to zero or all bits off. The extern storage class is used to declare a global variable that will be known to the functions in a file and capable of being known to all functions in a program. This storage class has a duration that is permanent. Any variable of this class retains its value until changed by another assignment. The scope is global. A variable can be known or seen by all functions within a program.


What is the difference between Declaration and Assignment?

Declaration is basically defining data type and length and assignment is to assign the value. Below is the declaration -- var a integer /* this means we are declaring a variable a as integer data type */ a= 5 /* this is assignment,we are assigning 5 to variable a */