liveBook · Manning

Binding

As explained in Modern C, Third Edition

A variable is a named object whose stored value can be accessed and may change during program execution.

A variable binding gives a named object a place to store a value during program execution. Keep four parts distinct: the object is the storage itself, the type specifies its kind, the value is the stored content, and the identifier is the name used to refer to it. section 2.2

Declarations create named storage

In `int argc;`, `argc` identifies a variable whose type is `int`. Likewise, `double A[5];` declares `A`, and `size_t I;` declares `I`. The declaration supplies the type and name; later statements can use operators such as `=` for initialization or assignment and `++` to increase a variable's value by one. section 2.2 section 2.1

Read a declaration by separating its roles:

  • `argc`, `A`, and `I` are identifiers used as names. section 2.2
  • `int`, `double`, and `size_t` specify the kind of object involved. section 2.2
  • The object and its value are conceptually different: a declaration names storage, while execution can give that storage a value. section 2.2
  • Not every identifier is a variable: identifiers can also name functions, type aliases, or constants. section 2.1
int main(int, char*[]);
int argc;
[[maybe_unused]] char* argv[];
double A[5];
size_t I;

Inspect the declarations together to compare variable names, types, arrays, and pointer syntax. section 2.2

How Modern C, Third Edition covers it

How deep it goes
Distinguishes object, type, value, and identifier, but defers pointer details and fuller type semantics.
Examples
Uses argc, i, A, and argv declarations, plus assignment and increment operators in a small C program.
What you can do after
Understand variable declarations and distinguish a variable's name, object, type, and stored value.
How it connects
Connects variables with identifiers, data objects, types, declarations, initialization, assignment, and increment.

Also explained in

Compare how 11 books explain binding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.