ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾C/C++±à³Ì£¾C Language Course
Introduction

This archive contains a complete course for you to learn the 'C' computer language itself.

The language used is correct conversational English, I have written the lessons using the same language constructions which I would use if I were teaching you directly.

An outline of the course is available for you to read below The course is intended to demonstrate the language itself and a selection of the simpler standard library functions.

I have assumed that you have had sufficient exposure to computing to be able to use a programmer's editor of your choice and are confident in the use of the command line interpreter, whether it be a unix shell, or a DOS ( shudder :-) prompt. Some knowledge, of computers and the jargon is assumed, but complicated concepts are fully explained. In other words the intent is to teach 'C' per se, not 'the fundamentals of how to program a computer using 'C' as a teaching medium.'

'C' is not a computer language for rank beginners. Start with an interpretive language and proceed to a compiled language which has an extensive error message vocabulary and run-time checking facilities. In the interests of speed of execution 'C' does very little to protect you from yourself!

Throughout the course the fact that a compiler is a translater from a high level language to assembler code is kept to the fore, you are frequently advised to examine the assembler code which is output by the compiler. Some minimal knowledge of computer architecture is therefore assumed.

Whilst I have taken considerable care to ensure that this material is free of errors I am well aware that to err is a common human failing, and in this I don't claim to be different from anybody else. Therefore your gentle critique is welcome together with notification of any factual errors.

It is planned to make the lessons available as a printed book, complete with a programme diskette if there is sufficient interest.

                     Syllabus for the 'C' Language Course.


    1   a) Historical introduction to the Language.

        b) Demonstration of a very simple program.

        c) Brief explanation of how the computer turns
           your program text into an executing program.

        d) The basic differences between 'C' and other languages.
           The advantages and disadvantages.

      We make the assumption that you are able to turn on your machine,
      use the Operating System at the Control Line Interpreter prompt
      "$ ", "c:>" or whatever, and to use an editor to enter program text.


    2   a) How the 'C' language arranges for the storage of data.
           An explanation of the keywords associated with data.
           The storage classes:- static auto volatile const.
           The variable types:- char int long float double
           The meaning of:- signed unsigned

        b) Introduction to the concept of pointers.

        c) Explanation of reading from the keyboard and writing to the screen.
           i.e. printf and scanf, the print formatted and scan formatted
                                   functions.

        d) The use of arguments to the main() function, argc argv env.

        e) A simple program to format text.


    3   Structures, arrays and pointers.

        a) Explanation of more coplex data structures.
        b) Programs which demonstrate uses of pointers.

    4   The operators of the language, arithmetic, pointer, logical, bitwise.

        a) Precedence.
        b) The unique bit and shifting operators.
           ( for a high level language )

    5   a) The Preprocesser.
        b) Header files

           What they are and what you put in them, both your own and
           those provided by the 'C' compiler vendor.

           A simple title which includes all sorts of things,
           both very useful and a number of traps.

    6   The library, why we have them and some of the more useful routines.

        a) How to read the book.
        b) The string functions as an example.

    7   a) Mistakes and how avoid making them.
        b) Debugging strategies.
        c) The assert macro.

    8   a) More on the representation of data vis. struct, typdef.

        b) Tables of all sorts.
           Arrays of structures.
           Pre-initialisation of data structures.
           ( Including jump or dispatch tables )
           The bit-field.

        c) Use of header files in this.


    9   a) The control structures of the language, what (not) to use and when.


   10   a) File IO

           This is an enormous subject and we we will
           really only just scratch on the surface.


   11   a) Lint, and more on errors / bugs and how to avoid them.


   12  The stack and a quick dip into assembler

       a) A study of the function calling mechanism used by most 'C'
          compilers and the effect on compiler output code of using
          the register storage class and the optimiser.

   13  The heap.

       a) The 'heap', it's management, malloc(), calloc() and free().


   14  Portability Issues.

       a) Defaults for storage sizes.
       b) 'endianism'. Yes, there are big-endian and little-endian computers!
       c) Functions which can be called with a variable number of arguments.


   15  Sample programs.

       Much is to be gained from examining public domain packages
       examining the code and reviewing the author's style.
       We will look at a number of functions and complete packages.
       in particular we will examine a number of sorting functions,
       a multi-threading technique, queues, lists, hashing, and trees.


               /* ----------------------------------------- */

Copyright notice:-

(c) 1993 Christopher Sawtell.

I assert the right to be known as the author, and owner of the intellectual property rights of all the files in this material, except for the quoted examples which have their individual copyright notices. Permission is granted for onward copying, but not modification, of this course and its use for personal study only, provided all the copyright notices are left in the text and are printed in full on any subsequent paper reproduction.

 +----------------------------------------------------------------------+
  NAME   Christopher Sawtell                                           
  SMAIL  215 Ollivier's Road, Linwood, Christchurch, 8001. New Zealand.
  EMAIL  chris@gerty.equinox.gen.nz                                    
  PHONE  +64-3-389-3200   ( gmt +13 - your discretion is requested )   
 +----------------------------------------------------------------------+