For students .:
1. int I;
2. int I = 0;
3. extern int I;
First, you can think of it as a definition or declaration. This is determined by different compilers, but most of them are declarations. They are defined only when I is assigned a value. it is declared. the compiler will tell me that this symbol has been reserved and the second symbol is not allowed in this scope.
The second type is defined. I will tell the compiler that I have already bound to this memory. Other variables cannot occupy this memory unless, A variable or object can only be defined once in a certain region. Therefore, if you define a variable repeatedly, an error is returned, indicating that the variable is already defined!
{
Int I = 0;
Int I = 1;
}
W1.c: In function 'main ':
W1.c: 6: 13: error: redefinition of 'I'
W1.c: 5: 13: note: previous definition of 'I 'was here
Third, any compiler will regard it as a declaration!
It can be simplified to: The definition creates a name, and remains unique in this scope, and opens up memory for this name. declaring that no memory is allocated only tells you that this symbol is available. it may be used below, otherwise it will tell you that it has not been declared.
From Crazybaby's blog