in Programming in C
1,865 views
1 vote
1 vote

If I write
 

#include<stdio.h>
int a;
main()
{
//code
}



then since a is a global variable so what is the storage class of it , is it extern ?

in Programming in C
1.9k views

1 comment

no, you don't have something like a default storage class for global variables in C programming. It always has a "static storage duration" which is not the same as "static storage class".

Refer here: https://stackoverflow.com/questions/3281925/what-is-default-storage-class-for-global-variables
0
0

2 Answers

3 votes
3 votes
Best answer

No, it is of static storage class because you have also defined variable here.

If you have written extern int a;, then it would have been of extern storage class.

Ref: http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/CONCEPT/storage_class.html

selected by

3 Comments

But in c by default storage specifier is auto..static keyword is always explicitly written..plz explain
1
1
0
0
It is of external linkage, but of static storage class.
2
2
0 votes
0 votes

in C ,by default global variable have extern  linkage

related  theory

Linkages of identifiers

3) If the declaration of a file scope identifier for an object or a function contains the storage-class specifier static, the identifier has internal linkage.

5) If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern. If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external.

reshown by

Related questions