The C Preprocessor

The basic (atomic) data types of C:

The structured data types of C:

Functions and Procedures

C functions and procedures have only one type of argument: pass by value. This means that modifying arguments in impossible
  • how do you modify something from within the calling program?
    In C this is done by passing a pointer to an object. The pointer itself does not alter, but the item pointed to and be changed. In a couple of weeks we will study this mechanism in detail. For now assume that all parameters are "call by value" or "import" parameters.
  • What types of object can functions return?
    Information is not returned explicitly via an "export" parameter, but rather a single item is returned via the function name (this item in turn may be a pointer to a whole bunch of stuff, but more of that in later lectures)

    The main program

    void main(int argc, char* argv[])
    The parameters to the main procedure are used to access the argument list supplied with the command to run the program. Why? The UNIX philosophy of passing substantial instructions via the command line, in order to reserve input and output for pipelining of data from one command (process) to another.

    Statements

    In class I do not expect you to understand the Gray-Code program in all its fine details. It is used only as a conversation piece so that I can talk about components of C-programs. In particular I should mention:

  • Bit-wise operation on words in memory and the use of a bit mask to select a specific bit or subset of bits.
  • scanf and printf for simple input and output.
  • Draw your attention to expressions and the embedding of function values within an expression [the so-called R-value]
  • The need for comments to specify the pre- and post-conditions
  • The need for use of a consistent style in programs.
  • Declaration of local variables
  • Some specially interesting assignment operators like += != and ^=