Cloudbook: C

  1. Home
  2. Control
  3. Block ← prevnext →
Blocks
  1. Blocks serve two functions: the allow placing a sequence of statements where syntax allows for a single statement, and they introduce variables — both the scope and lifetime of the introduced variable is determined by the block.
  2. A block introduces a new scope, and variables declared at the top of the block are in scope until the end of the block. if a variable exists with the same name outside the block, that variable is hidden, and cannot be referred to inside the block. more ...

    LiveC: Block scoping example. more ...

    Multimedia presentation goes here.
  3. In 1968, Edgar Dijkstar declared that the goto statement [is] considered harmful. The C programming language is a block structured language that, while retaining the goto statement, prefers code that avoids gotos.

    Block structure means that code flow be restricted to entire blocks, and upwards flow of control be cause by looping constructs that control the block. This discipline makes reasoning about programs easier.

    Exceptions to this strict control discipline, which retain block structure advantages, are provided by the break and continue statements. more ...

    LiveC: Mystery code: what does it do? more ...

    Multimedia presentation goes here.
  4. Blocks introduce lifetimes. An automatic variable, such as a variable declared inside a block, being a procedure block or a block nested inside the procedure block, has lifetime beginning at entry to the block, and ending when exiting the block. This might be difficult to observe experimentally. more ...

    ref: gnu.org

    LiveC: "It's like you're unraveling a big cable-knit sweater ..." more ...

    Multimedia presentation goes here.
Copyright 2015, 2017 Burt Rosenberg. All Rights Reserved.