In the C language, for definitions and declarations, perhaps we are very familiar with, but not necessarily really understand!
Definition means: The definition is to create a (compiler) an object, to allocate a memory space for this object and name, that is, the name of the variable or object that we normally call, once this is a memory space match, then in the definition of this object or variable life cycle, The variable name created cannot be changed, and the location of the memory space will not change. Within a region (within a function, global), a name can only be defined once and cannot be defined repeatedly.
Meaning of the Declaration: the declaration has a twofold meaning
First meaning: Tell the compiler that the name has been matched to a piece of memory space, and that the variable or object used in the subsequent code is defined somewhere else.
Eg:extern int I:
The second meaning: Tell the compiler, this name I have scheduled, such as the most familiar function declaration: void Fun (int i,char c); At the very beginning, it means telling the compiler that the name has been scheduled, and that the other variables or objects in the subsequent code will no longer be able to use the name. Declarations can be repeated multiple times.
Key differences in definition and declaration:
The definition creates an object and allocates memory space, whereas the Declaration does not allocate memory space.
-------Summary from the "C Language Depth Analysis"
What is the meaning of definition in C language? What does the statement mean? What is the difference between them?