using auto variables for global scope

c

Solution

Variables at top-level cannot be `auto`. They should be either declared `static`, `extern` (definition elsewhere) or global (no keyword for that).

This won't compile.

$ echo "auto int c;" > test.c
$ gcc -Wall -c test.c
test.c:1:10: error: file-scope declaration of ‘a’ specifies ‘auto’

Problem

``` auto int a=5; #include<stdio.h> int main () { printf("%d",a); return 0; } ``` I have read that the scope of automatic variables is within the specified block . In the above program, since the auto variable 'a' is declared outside main function, it should be assigned global scope and be accesible within the main . But, there seems to be an error .

Original source