                      Introduction to the C Tutorial


             The programming language C, was originally developed by 
        Dennis  Ritchie of Bell Laboratories and was designed to run 
        on a PDP-11 with a UNIX operating system.   Although it  was 
        originally  intended  to run under UNIX,  there has  been  a 
        great  interest  in  running it under the  MS-DOS  operating 
        system and specifically on the IBM PC and  compatibles.   It 
        is an excellent language for this environment because of the 
        simplicity of expression,  the compactness of the code,  and 
        the wide range of applicability. 

             It  is  not a good "beginning" language because  it  is 
        somewhat cryptic in nature.  It allows the programmer a wide 
        range of operations from high level down to a very low level 
        approaching the level of assembly language.   There seems to 
        be no limit to the flexibility available.  One experienced C 
        programmer made the statement,  "You can program anything in 
        C", and the statement is well supported by my own experience 
        with  the  language.    Along  with  the  resulting  freedom 
        however,  you take on a great deal of responsibility because 
        it is very easy to write a program that destroys itself  due 
        to  the  silly little errors that the Pascal  compiler  will 
        flag  and call a fatal error.   In C,  you are very much  on 
        your own as you will soon find.

             Since C is not a beginners language,  I will assume you 
        are  not a beginning programmer,  and I will not attempt  to 
        bore you by defining a constant and a variable.  You will be 
        expected to know these basic concepts.   You will,  however, 
        be  expected to know nothing of the C programming  language.  
        I  will begin with the most basic concepts of C and take you 
        up  to  the  highest level of C  programming  including  the 
        usually intimidating concepts of pointers,  structures,  and 
        dynamic allocation.   To fully understand these concepts, it 
        will  take a good bit of time and work on your part  because 
        they  not  particularly easy to grasp,  but  they  are  very 
        powerful tools.   Enough said about that, you will see their 
        power when we get there,  just don't allow yourself to worry 
        about them yet.

             Programming  in C is a tremendous asset in those  areas 
        where you may want to use Assembly Language but would rather 
        keep it a simple to write and easy to maintain program.   It 
        has been said that a program written in C will pay a premium 
        of  a 50 to 100% increase in runtime because no language  is 
        as compact or fast as Assembly Language.   However, the time 
        saved  in  coding  can be tremendous,  making  it  the  most 
        desirable   language  for  many  programming   chores.    In 
        addition,  since  most  programs spend 90 percent  of  their 
        operating time in only 10 percent or less of the code, it is 
        possible  to  write  a program in C,  then rewrite  a  small 
        portion  of the code in Assembly Language and  approach  the 


                                  Page 1









                      Introduction to the C Tutorial


        execution  speed  of  the same program if  it  were  written 
        entirely in Assembly Language.

             Approximately 75 percent of all new commercial programs 
        introduced  for the IBM PC have been written in C,  and  the 
        percentage   is   probably  growing.    Microsoft   recently 
        introduced a new Macro Assembler, version 4.0, and they said 
        that it was written in C.  There are probably a few routines 
        coded in Assembly Language,  but the majority was written in 
        C. 

             Since C was designed essentially by one person, and not 
        by  a committee,  it is a very usable language but  not  too 
        well defined.   There is no standard for the C language, but 
        the   American  National  Standards  Association  (ANSI)  is 
        developing a standard for the language at which time it will 
        follow  rigid rules.   It is interesting to  note,  however, 
        that  even  though  it  does  not  have  a   standard,   the 
        differences between implementations are very small.  This is 
        probably  due  to  the  fact that  the  original  unofficial 
        definition  was  so well thought out and  carefully  planned 
        that  extensions to the language are  not  needed.   Pascal, 
        which  has  a rigorous definition,  has many  extensions  by 
        compiler  writers  and every extension is  different.   This 
        leads  to a real problem when transporting a Pascal  program 
        from one computer to another.

             Even  though the C language enjoys a good  record  when 
        programs are transported from one implementation to another, 
        there  are differences in compilers as you will find anytime 
        you  try to use another compiler.   Most of the  differences 
        become apparent when you use nonstandard extensions such  as 
        calls  to  the DOS BIOS,  but even these differences can  be 
        minimized by careful choice of programming means. 

             Your first problem will not be how to program in C, but 
        how to use your particular compiler.   Since there are  over 
        20 good compilers available, there is no way I can cover the 
        operation of all compilers.  Notes about a few of the better 
        known  compilers are given in the "COMPILER.DOC" file on the 
        distribution  diskette.   Read the documentation  that  came 
        with  your  compiler  to  learn how to  compile  and  run  a 
        program.

              One  last note about compilers.   I wrote a moderately 
        large program in C that was composed of about 1200 lines  of 
        source code contained in 4 separately compiled files.  I was 
        initially   using  a  very  inexpensive  compiler  from  MIX 
        Software of Richardson,  Texas that sells for $39.95.   This 
        compiler  did  everything I ever asked it to do and  did  it 
        well,  including floating point numbers.   In addition,  the 


                                  Page 2









                      Introduction to the C Tutorial


        compile  times  were  extremely short and  there  were  many 
        extensions  to the basic language as defined by  Kernigan  & 
        Ritchie.   In short, the compiler was a good implementation.  
        Later,  I  switched over to a Lattice C compiler that  sells 
        for  $500.00.   It  took a bit of work because  the  Lattice 
        compiler  did  not  have  as  many  extensions  as  the  MIX 
        compiler.   The  Lattice  compiler  also  took  considerably 
        longer to compile,  probably 2 to 3 times as long.   The big 
        difference in the two compilers was in the execution time of 
        the program which read in a file,  did a lot of searching in 
        memory, and displayed the results on the monitor.  The final 
        MIX program took 95 seconds to complete all operations,  and 
        the  Lattice  compiled  program  took  only  10  seconds  to 
        complete.   I should add that the MIX compiler has a speedup 
        utility  that  increases the speed by a factor of  about  8, 
        according  to one independent review,  getting the speed  of 
        the MIX program in the range of the Lattice program.  (I did 
        not  try the speedup program on this particular file.)   The 
        MIX  compiler  missed  several  subtle  type  errors  during 
        compile  that  were  flagged  as  warnings  by  the  Lattice 
        compiler.   Due  to  the nature of that particular  program, 
        either  run-time  would be acceptable and  therefore  either 
        compiler would be acceptable.

             The  above  paragraph  was  given only to  aid  you  in 
        selecting  a  compiler.    The  Lattice  compiler  is   very 
        difficult  to use for an inexperienced programmer,  but  has 
        very few limitations.   The MIX compiler, on the other hand, 
        was  very easy to set up and begin using,  and would be very 
        appropriate for  most "hobby" computing.   Depending on your 
        application,  the  most expensive is probably not the  best.  
        In this case,  the MIX compiler would be great for  learning 
        the language and for many applications. 

             Consult  the  COMPILER.DOC  file  for  notes  on  other 
        compilers  and  recommendations  on  what  compiler  may  be 
        suitable for your purposes.
















                                  Page 3

