int a in the file area is a โpreliminaryโ definition (since it does not have the initialization part). This means that a can again be defined with a value at a later point.
A preliminary determination may or may not act as a definition, depending on whether there is an actual external definition before or after it in the translation unit:
int a = 5; // defines a in the current translation unit with external linkage and a value of 5 int a; // tentative definition with no effect (a is already defined)
Another method, as a rule, has more practical advantages:
int a; ... int a = 5;
A preliminary determination may precede the actual determination if, for example, the constant used for initialization is not available at the first point.
Edit:
It seems you are confused that you cannot perform the assignment in the file area. Program C is only allowed to have actual operations inside functions. Only files, types, and functions can be defined or declared in the file area.
Blagovest buyukliev
source share