home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1995 December / SOFM_Dec1995.bin / pc / dos / gi / ctutor / chap1.txt < prev    next >
Text File  |  1995-10-31  |  7KB  |  190 lines

  1.                         Chapter 1 - Getting Started
  2.  
  3.  
  4.                           WHAT IS AN IDENTIFIER?
  5.  
  6.              Before you can do anything in any language, you must at
  7.         least  know  how you name an identifier.  An  identifier  is
  8.         used  for any variable, function, data definition, etc.   In
  9.         the  programming language C, an identifier is a  combination
  10.         of alphanumeric characters, the first being a letter of  the
  11.         alphabet or an underline, and the remaining being any letter
  12.         of  the alphabet, any numeric digit, or the  underline.   In
  13.         the  case of Turbo C, a dollar sign is permitted but not  as
  14.         the first character of an identifier.  It should be  pointed
  15.         out that even though a dollar sign is permitted by the Turbo
  16.         C  compiler, it is not used anywhere in this tutorial  since
  17.         it  is not in general use by C programmers, and is not  even
  18.         allowed by most compilers.  If you do not plan to write  any
  19.         portable  code, you can use it at will if you feel it  makes
  20.         your code more readable.
  21.  
  22.              Two rules must be kept in mind when naming identifiers.
  23.  
  24.         1.   The  case  of  alphabetic  characters  is  significant.
  25.              Using  "INDEX" for a variable is not the same as  using
  26.              "index"  and  neither  of them is  the  same  as  using
  27.              "InDeX"  for a variable.   All three refer to different
  28.              variables.
  29.  
  30.         2.   As Turbo C is defined, up to 32 significant  characters
  31.              can  be  used and will be considered  significant.   If
  32.              more  than  32 are used, they will be  ignored  by  the
  33.              compiler.  You can reduce the number used  to  anything
  34.              less  than 32 if you desire as a compiler option.   You
  35.              should  not do this for the duration of your  study  of
  36.              this  tutorial  as  you could  get  some  odd  compiler
  37.              diagnostics.
  38.  
  39.                          WHAT ABOUT THE UNDERLINE?
  40.  
  41.              Even  though  the  underline can be used as part  of  a
  42.         variable  name, and adds greatly to the readability  of  the
  43.         resulting  code,  it  seems  to  be  used  very  little   by
  44.         experienced   C  programmers.   It  adds  greatly   to   the
  45.         readability  of  a  program to  use  descriptive  names  for
  46.         variables  and  it  would be to your  advantage  to  do  so.
  47.         Pascal  programmers tend to use long descriptive names,  but
  48.         most C programmers tend to use short cryptic names.  Most of
  49.         the  example programs in this tutorial use very short  names
  50.         for that reason.
  51.  
  52.              Any computer program has two entities to consider,  the
  53.         data,  and  the program.   They are highly dependent on  one
  54.         another  and  careful planning of both will lead to  a  well
  55.  
  56.  
  57.                                  Page 4
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                         Chapter 1 - Getting Started
  68.  
  69.  
  70.         planned and well written program.   Unfortunately, it is not
  71.         possible  to study either completely without a good  working
  72.         knowledge of the other.  For this reason, this tutorial will
  73.         jump  back  and forth between teaching  methods  of  program
  74.         writing  and  methods of data  definition.    Simply  follow
  75.         along and you will have a good understanding of both.   Keep
  76.         in  mind that,  even though it seems expedient to  sometimes
  77.         jump right into the program coding,  time spent planning the
  78.         data  structures  will be well spent and the  final  program
  79.         will reflect the original planning.
  80.  
  81.                         HOW THIS TUTORIAL IS WRITTEN
  82.  
  83.              As  you go through the example programs,  you will find
  84.         that  every  program  is complete.   There  are  no  program
  85.         fragments that could be confusing.   This allows you to  see
  86.         every  requirement that is needed to use any of the features
  87.         of  Turbo  C as they are presented.  Some tutorials  I  have
  88.         seen give very few, and very complex examples.  They  really
  89.         serve  more  to confuse the student.  This tutorial  is  the
  90.         complete  opposite  because  it strives to  cover  each  new
  91.         aspect  of programming in as simple a context  as  possible.
  92.         This  method, however, leads to a lack of knowledge  in  how
  93.         the  various parts are combined.  For that reason, the  last
  94.         chapter is devoted entirely to using the features taught  in
  95.         the  earlier  chapters. It will illustrate how  to  put  the
  96.         various features together to create a usable program.   They
  97.         are given for your study, and are not completely  explained.
  98.         Enough details of their operation are given to allow you  to
  99.         understand how they work after you have completed all of the
  100.         previous lessons.
  101.  
  102.              At this point, you should load and run FIRSTEX.C if you
  103.         have  not yet done so, to see that the Turbo C  compiler  is
  104.         properly  loaded and operating.  If you have  any  problems,
  105.         see  the COMPILER.DOC file for help in properly  setting  up
  106.         your computer to compile and run Turbo C programs.
  107.  
  108.                      A DISCUSSION OF SOME OF THE FILES
  109.  
  110.                                   LIST.EXE
  111.  
  112.              This  file will list the source files for you with line
  113.         numbers  and  filename.   To  use  it,  simply  type  "LIST"
  114.         followed by the appropriate filename.   Type LIST  FIRSTEX.C
  115.         now  for  an example.   The C source code is given later  in
  116.         Chapter 14 along with a brief description of its operation.
  117.         After  you  have completed your study of Turbo C,  you  will
  118.         have the ability to read and understand the source code  for
  119.         this program.
  120.  
  121.  
  122.  
  123.                                  Page 5
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                         Chapter 1 - Getting Started
  134.  
  135.  
  136.                                 PRINTALL.BAT
  137.  
  138.              This is a batch file that will call the above  LIST.EXE
  139.         file  once for each of the example C programs,  printing all
  140.         of  the  files out.   If you want a hardcopy of all  of  the
  141.         files,  enter PRINTALL and watch as your printer fills about
  142.         150 sheets of paper with C programs.
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.                                  Page 6
  190.