home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / turbo_c / trboctxt.arc / CHAP1.TXT next >
Text File  |  1988-02-01  |  7KB  |  191 lines

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