home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / cnews017.zip / CNEWS017.DOC next >
Text File  |  1989-09-25  |  31KB  |  963 lines

  1.  
  2.       Issue 17                     C News                             1
  3.  
  4.  
  5.       *--------------------------------------------------------------*
  6.       |    C NEWS - International C Electronic Newsletter/Journal    |
  7.       |           "Dedicated to the Art of C Programming"            |
  8.       |                                                              |
  9.       |                      Founded 12/27/87                        |
  10.       *--------------------------------------------------------------*
  11.  
  12.  
  13.                               Table of Contents
  14.  
  15.       THE HEAP: Messages from the Editor   ......................    2
  16.  
  17.       COMMAND LINE ARGUMENTS IN C by Jim Singleton ..............    4
  18.  
  19.       BOOK REVIEW by Jim Singleton    ...........................    6
  20.  
  21.       BEGINNERS CORNER: By Wayne Dernoncourt    .................    8
  22.  
  23.       PEPTO: A SHAREWARE SOURCE CODE COMPRESSOR by Jim Singleton.   13
  24.  
  25.       ARTICLE SUBMISSION STANDARDS      .........................   15
  26.  
  27.       HOW TO GET HOLD OF US HERE AT CNEWS........................   16
  28.  
  29.  
  30.  
  31.       "C  News"  is  an  Electronic  Journal published by the C BBS in
  32.       Burke,  VA  on  a monthly basis. The subject for C News is the C
  33.       programming language, as well as any derivatives like C++.  
  34.  
  35.       All  readers  are  encouraged  to  submit  articles, reviews, or
  36.       comments  for submission.  C News is freely distributed, but can
  37.       not  be  sold  for a profit, or cannot have a charge assessed to
  38.       cover  distribution costs.  All articles, and reviews become the
  39.       property   of   C   News   and   cannot  be  included  in  other
  40.       publications   without   written  permission  from  the  C  News
  41.       Editorial  Staff.  To do so is in direct violation of the C News
  42.       License  agreement.   Copies  of  which are available from the C
  43.       BBS.    This  publication  is  Copyrighted  under  U.S. Copyright
  44.       Law.
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.       
  60.  
  61.  
  62.  
  63.  
  64.       Issue 17                     C News                             2
  65.  
  66.  
  67.       ================================================================= 
  68.       THE HEAP: Messages from the Editor   
  69.       ================================================================= 
  70.  
  71.  
  72.  
  73.            Welcome to another issue of C News.  Jim, Dan, and Wayne
  74.       have worked hard to put this issue together, and deserve a round
  75.       of applause for their fine efforts.  
  76.  
  77.            A couple of weeks ago, I placed a message in the Fidonet C
  78.       Echo asking for ideas on articles for C News.  The response was
  79.       excellent.  The C News staff and I will be reviewing the ideas
  80.       that have been submitted and determine which subjects we can
  81.       cover and in what issue they will appear.  As always, you are
  82.       encouraged to submit ideas to the C BBS, via postal mail or MCI
  83.       mail.  
  84.  
  85.            One area that we will begin a series on in the next issue
  86.       is sort and search algorithms, to include: Quicksort,
  87.       Bubblesort, B-Trees, and Linked Lists.  Each algorithm will be
  88.       presented in theory, pseudocode and a 'c' code example.  
  89.  
  90.            Also, if time permits in the next few months, I will begin
  91.       a beginners column in MS Windows programming.  I would also like
  92.       to cover OS/2 programming as the two are closely related.
  93.       However the cost of the OS/2 development kit prohibits me from
  94.       exploring the latter.  Maybe in time, Microsoft may decide to
  95.       lower the cost to something reasonable.  
  96.  
  97.            Sometime later in the week, I will be sending all of the C
  98.       News issues to date to the "C Users Group" for inclusion in
  99.       their library.  I'll let you know whether CUG accepts the disks
  100.       or not in the next issue of C News.  
  101.  
  102.            C News also has a new "European" C News BBS and Editor.
  103.       The newcomer to the C News staff is Rob Koel, a young computer
  104.       professional in Holland.  Rob runs a BBS in holland that has
  105.       it's own C News section which contains all of the issues of C
  106.       News, and a message section where you can leave messages to us.
  107.       Rob will pack of the message sand forward them to us here in the
  108.       US.  As soon as Rob, let's me know his BBS number I will post it
  109.       here in this column.   
  110.  
  111.            Finally, Jim Singleton represented C News at the East Coast
  112.       SOG in York, PA this month.  Jim presented C News and discussed
  113.       the future of the newsletter and solicited thoughts and ideas on
  114.       C News.  Jim and I have not had a chance to talk since the SOG,
  115.       I will fill you in on the details in the next issue.  
  116.  
  117.            Thanks for the continued support, and we look forward to a
  118.       continued relationship with our readers and friends around the
  119.  
  120.  
  121.       
  122.  
  123.  
  124.       Issue 17                     C News                             3
  125.  
  126.  
  127.       globe.  Keep those postcards coming!!! 
  128.  
  129.       Barry Lynch 
  130.  
  131.       Editor - C News 
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  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.       Issue 17                     C News                             4
  185.  
  186.  
  187.       ================================================================= 
  188.       COMMAND LINE ARGUMENTS IN C by Jim Singleton 
  189.       ================================================================= 
  190.  
  191.  
  192.  
  193.            I was looking through a C text the other day (see the
  194.       review of "The Spirit of C:  An Introduction to Modern
  195.       Programming" elsewhere in this issue) and I noticed that the
  196.       very last topic which was covered was passing command-line
  197.       parameters.  I admit that passing command-line parameters is
  198.       probably not one of the first topics which a C programmer should
  199.       learn.  After all, how many parameters do you need to pass to
  200.       print "Hello world"?  At the same time, I can see an argument
  201.       for covering the topic a bit earlier, perhaps when discussing
  202.       functions.  It's really just a special case of passing a
  203.       parameter to a function -- which happens to be main().  Anyway,
  204.       if you've ever wondered how to pass a parameter on the
  205.       command-line, just read on.  
  206.  
  207.            In order to pass a parameter to the program, main() must be
  208.       defined as having two arguments, as shown: 
  209.  
  210.            void main(int argc, char *argv[])
  211.            {
  212.               . . . 
  213.            }
  214.  
  215.       Where argc is an integer value representing the number of
  216.       arguments typed on the command-line.  The second argument,
  217.       argv[], is an array of character pointers.  While these
  218.       arguments may also be declared as: 
  219.  
  220.            void main(argc, argv)
  221.            int argc;
  222.            char **argv;
  223.            {
  224.                 }
  225.  
  226.       these arguments must be declared as the type shown.  
  227.  
  228.            The first value of this array of character pointers,
  229.       argv[0], is always the name of the program.  For example, let's
  230.       assume we have a program called READ and it's executed, in DOS,
  231.       as: 
  232.  
  233.            C> read [filename]
  234.  
  235.       We would enter: 
  236.  
  237.            C> read CNEWS017.NWS
  238.  
  239.  
  240.  
  241.       
  242.  
  243.  
  244.       Issue 17                     C News                             5
  245.  
  246.  
  247.       In this example, argc has a value of 2 (for the program and the
  248.       filename), argv[0] is "read" and argv[1] is "CNEWS017.NWS".  If
  249.       we were to enter: 
  250.  
  251.            C> read CNEWS017.NWS ASCII
  252.  
  253.       we would find: 
  254.  
  255.            argc = 3
  256.            argv[0] == "read"
  257.            argv[1] == "CNEWS017.NWS"
  258.            argv[2] == "ASCII"
  259.  
  260.            You may have noticed that the arguments passed are always
  261.       stored as character strings.  If we have: 
  262.  
  263.            C> read CNEWS017.NWS 2
  264.  
  265.       We find that argv[2] is a pointer to the character string "2".
  266.       In order to use this value as a number, the program must convert
  267.       the string.  This is easily accomplished by using functions such
  268.       as atof(), atoi(), etc.  
  269.  
  270.            The program DICE.C is an example of a program which
  271.       requires passing a parameter upon execution.  (Two versions of
  272.       DICE.C, one for Turbo C and one for Microsoft C/Quick C, are
  273.       contained in the accompanying file DICE.LZH.)  As the program
  274.       simulates the rolling of a user-specified number of dice, the
  275.       number of the dice is entered at the time of execution.  In this
  276.       example, the number of dice, which is stored as a character
  277.       string, must be converted to an integer, which is done using
  278.       atoi().  DICE.C also shows how the value of argc can be used to
  279.       determine that the correct number of parameters has been
  280.       entered.  
  281.  
  282.            While we have seen that passing parameters to a program
  283.       upon execution isn't hard, don't get carried away with command-
  284.       line arguments.  We wouldn't want something like: 
  285.  
  286.            C> read CNEWS017.NWS -ascii -double-spaced -odd-pages
  287.               -titled -two-per-screen
  288.  
  289.       would we?  (Okay, okay, if we were using Berkeley Unix we would,
  290.       but otherwise, we would not.)  Besides, the more parameters that
  291.       can be passed, the more complicated the program is for the
  292.       user.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.       
  302.  
  303.  
  304.       Issue 17                     C News                             6
  305.  
  306.  
  307.       ================================================================= 
  308.       BOOK REVIEW by Jim Singleton    
  309.       ================================================================= 
  310.  
  311.  
  312.            Title:  The Spirit of C
  313.                    An Introduction to Modern Programming (Student Copy)
  314.  
  315.            Author/s:  Henry Mullish and Herbert L. Cooper
  316.  
  317.            Publisher:  West Publishing Company
  318.                        50 West Kellog Boulevard
  319.                        P. O. Box 64526
  320.                        Saint Paul, MN  55164-1003
  321.  
  322.            ISBN #:  0-314-28500-8
  323.  
  324.            Unlike most of the books which have been reviewed in the C
  325.       NEWS, "The Spirit of C An Introduction to Modern Programming" is
  326.       somewhat different because it is a textbook.  (The only other
  327.       books reviewed in the C NEWS which I would consider textbooks
  328.       might be Thomas Plum's "Learning to Program in C" and "Reliable
  329.       Data Structures in C".) Before you say, "Oh, it's a textbook, it
  330.       must be boring" and stop reading this review, hold on a minute.
  331.       Of all the textbooks I own, from all the classes I've taken,
  332.       this is the only one which is usually within reach.  I say
  333.       "usually" because I normally keep it at work, as one of my two C
  334.       references. (There are other C books, a number of them, sitting
  335.       above my computer at home.) 
  336.  
  337.            One thing, which I have to point out, that separates "The
  338.       Spirit of C" from all other C books I have read or looked
  339.       through is the first example program.  Rather than the normal
  340.       "Hello world" program, the first program is an interactive
  341.       program to calculate the hypotenuse of a right triangle.  Had
  342.       this been the first C program I had ever seen, I'd have probably
  343.       gone back to whatever language I was using before C!  Luckily,
  344.       the first program for the reader is asked to enter is much
  345.       simpler.  
  346.  
  347.            "The Spirit of C" is a very readable text.  It's not a book
  348.       I might take to the beach (then again, I have taken programming
  349.       books on vacation, so...); but it is a lot less dry than most
  350.       textbooks, especially the textbook I learned FORTRAN from.  The
  351.       sixteen chapters are well organized and filled with example
  352.       programs.  Virtually every example program has an example of its
  353.       output immediately following the program.  
  354.  
  355.            Each chapter is divided into four parts.  The first part
  356.       goes into the topics which are covered in that particular
  357.       chapter.  The second part is titled, "The Spirit of C" and is
  358.       used to illustrate the material covered in the chapter by
  359.  
  360.  
  361.       
  362.  
  363.  
  364.       Issue 17                     C News                             7
  365.  
  366.  
  367.       demonstrating the solution of a real life programming problem.
  368.       Also included in this section are discussions of programming
  369.       style, debugging (starting with chapter 5), and other related
  370.       topics.  The third section of each chapter is a series of
  371.       questions concerning the information presented in the chapter,
  372.       followed by the answers.  The fourth and final section of each
  373.       chapter is a number of programming exercises.  Unfortunately,
  374.       the solutions to these programming problems are not in the text,
  375.       but are included in the instructors edition.  
  376.  
  377.            At the end of the book, where the answers to the
  378.       programming problems should be, are six appendices:  a C
  379.       reference guide, common library functions, ASCII character
  380.       codes, a discussion of UNIX, a listing of keywords, and a guide
  381.       to the programming debugging hints presented elsewhere in the
  382.       book.  The appendices are followed by a good index.  
  383.  
  384.            Easy to read and loaded with examples, "The Spirit of C"
  385.       sounds like the ideal book to learn C from.  While I am sure you
  386.       could learn to program from this book, without an instructor
  387.       (look at the people who have learned C from K&R), I wouldn't
  388.       recommend it as a first book.  Why?  That's hard to say.  It
  389.       wasn't the first book on C I had read, but when I spoke to some
  390.       students who were using it in a class, who had not been exposed
  391.       to C, almost all had reservations about it and had gotten some
  392.       other introductory C book.  Another strike against it is that it
  393.       is rather hard to find, especially outside of a college
  394.       bookstore.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.       
  422.  
  423.  
  424.       Issue 17                     C News                             8
  425.  
  426.  
  427.       ================================================================= 
  428.       BEGINNERS CORNER: By Wayne Dernoncourt    
  429.       ================================================================= 
  430.  
  431.  
  432.  
  433.            In the last article we discussed the concept of passing
  434.       back multiple pieces of data from a function.  As part of this
  435.       discussion the concept of an address was introduced, along with
  436.       reading and writing data at this address.  This was all
  437.       discussed along with scope - that is, how long data is good
  438.       for.  This month we're going to step back and look at how
  439.       functions that are supplied with the operating system pass data
  440.       back and forth (this will be done primarily through the use of
  441.       file system calls).  Next month we're going to continue to look
  442.       at how file I/O is performed.  The month after that we're going
  443.       to discuss writing and using your own data structures.  
  444.  
  445.            One of the most elementary things that a program does is
  446.       create a file.  That's one item that we haven't done yet.  This
  447.       will be remedied in this article.  
  448.  
  449.            To start off with, the operating system (most operating
  450.       systems, anyway) needs some information before it can work with
  451.       files.  For example, the operating system has to know the name
  452.       and location (i.e.  the pathname) of the file, and it has to
  453.       know how you're going to call it (i.e. which one of several
  454.       files or printers that you're currently using - which one do you
  455.       want to use).  Also you should tell it whether you're going to
  456.       read the file or write the file and whether you want to treat
  457.       the file as a text file or as a binary file.  All of this
  458.       information is usually specified in the 'open' statement.  For
  459.       our first example we are going to come up with a program to fill
  460.       the following need.  A user has a file of a scanned (digitized)
  461.       drawing stored in the computer in a known format (i.e.
  462.       AutoCad).  However, the scanner software didn't block the file
  463.       into the needed 80 character records, it left it as one record
  464.       that was 350,000 characters long.  The requirement is to read in
  465.       the original file and insert a new line character after every 80
  466.       characters.  In our first example, instead of an 'open'
  467.       statement, we're going to use an 'fopen' statement.  It performs
  468.       the same function, but is specifically intended for buffered
  469.       file I/O.  
  470.  
  471.            The following pseudo-code is designed to fill this need.
  472.       As the name implies, pseudo-code isn't real program code.  There
  473.       is more English, but it doesn't have all of the control
  474.       structures that will be needed.  But it serves as a stepping
  475.       stone between the problem statement and definition and the
  476.       program source code.  
  477.  
  478.  
  479.  
  480.  
  481.       
  482.  
  483.  
  484.       Issue 17                     C News                             9
  485.  
  486.  
  487.       /* This program is to demonstrate how to use files */
  488.       /*
  489.       Open an input file <-on error quit->
  490.       open an output file <-on error quit->
  491.       initialize a counter to zero that will track the number of
  492.               characters going into the output for each record
  493.       until you hit the end of file (EOF), do the following:
  494.               read a character
  495.               write a character
  496.               increment counter
  497.               if counter is greater than 79 then
  498.                       write a new line
  499.                       reset counter to zero
  500.               end-if
  501.       end-until
  502.  
  503.            This is the C source code that has been written from the
  504.       pseudo-code above.  Notice that there are some changes between
  505.       the two, but that on the whole the program follows the
  506.       pseudo-code.  
  507.  
  508.       #include <stdio.h>
  509.  
  510.       main()
  511.       {
  512.               int char_cnt = 0;  /* This is our increment counter */
  513.               char in_char;      /* This is the character variable */
  514.               FILE *in, *out;    /* Set up pointers to file data structures */
  515.  
  516.               if ((in = fopen("notes.log", "rt")) == NULL)
  517.               {
  518.                       fprintf (stderr, "Oops, where is input file at?\n");
  519.                       return(1);
  520.               }
  521.  
  522.               if ((out = fopen("notes.new", "wt")) == NULL)
  523.               {
  524.                       fprintf (stderr, "Oops, how about the output file");
  525.                       return(1);
  526.               }
  527.  
  528.               while (!feof(in))
  529.               {
  530.                       in_char = fgetc(in);
  531.                       fputc (in_char, out);
  532.                       char_cnt++;
  533.                       if (char_cnt > 79)
  534.                       {
  535.                               fputc('\n', out);
  536.                               char_cnt = 0;
  537.                       }
  538.               }
  539.  
  540.  
  541.       
  542.  
  543.  
  544.       Issue 17                     C News                            10
  545.  
  546.  
  547.               fclose(in);
  548.               fclose(out);
  549.       }
  550.  
  551.            The 'fopen' call takes the information from the function
  552.       arguments and creates a data structure of type FILE.  Some of
  553.       this information is supplied by the operating system when the
  554.       'fopen' call is used.  Examples of the information stored in the
  555.       data structure include the file status (read only, write only,
  556.       read write, etc.), the error status, a file descriptor, buffer
  557.       size (the buffer size on a floppy is usually smaller than that
  558.       of a hard disk), the address of the data transfer buffer and a
  559.       currently active pointer.  
  560.  
  561.            The values returned by the 'fopen' calls are pointers to
  562.       the memory locations where the data structures reside.  These
  563.       are assigned to the variables 'in' and 'out'.  These variables
  564.       are then checked for equality to 'NULL'.  NULL is a macro
  565.       defined in the stdio.h header file that is the value returned by
  566.       'fopen' when an error has occurred.  In many C implementations
  567.       this macro is a synonym for 0, but portable code should not rely
  568.       on this as it is not always true.  
  569.  
  570.            Anyway, if the 'in' and 'out' pointer variables aren't
  571.       NULL, this implies that the files could be opened.  More
  572.       specifically, the first file existed and could be opened and
  573.       that the second file could be created.  The double equal sign in
  574.       the 'if' statement is how the C language denotes the equality
  575.       condition check, i.e. make sure that the variable 'in' is equal
  576.       to 'NULL'.  If either variable is equal to NULL, print out an
  577.       error message and stop the program.  You may have noticed that
  578.       three operations actually take place in these first two 'if'
  579.       statements: 
  580.  
  581.               1. A file is opened for either reading or writing
  582.               2. An assignment to a pointer variable is made
  583.               3. The pointer variable is checked for validity
  584.  
  585.            The next thing that may strike you as a bit odd is the
  586.       expression: 
  587.  
  588.            while (!feof(in)) 
  589.  
  590.            What this expression means is that while the expression in
  591.       the parentheses is true, do whatever follows the expression.  In
  592.       this particular case, feof(in) is a macro to determine whether
  593.       or not the end of the file has been reached, the value of the
  594.       expression is true if the end of the file has been reached,
  595.       otherwise it's false.  The leading exclamation mark negates the
  596.       expression that follows.  So what this whole line means in
  597.       english is "do the following until I hit the end of the input
  598.       file".  
  599.  
  600.  
  601.       
  602.  
  603.  
  604.       Issue 17                     C News                            11
  605.  
  606.  
  607.  
  608.            The 'fgetc' function gets a character from the input file
  609.       (this is singular, not plural) and assigns it to the variable
  610.       'in_char'.  The same character is then written to the output
  611.       file and the number of characters written to that output record
  612.       is then incremented by one.  
  613.  
  614.            Let's talk about this last operation in a little bit more
  615.       detail. Back in the second issue of this column, I talked about
  616.       the following operations: 
  617.  
  618.               1. +=
  619.               2. -=
  620.               3. /=
  621.               4. *=
  622.  
  623.            It turns out there are another class of operators called
  624.       the increment/decrement operators.  These operate just as you
  625.       might imagine, they either increment or decrement the variable
  626.       being operated on.  The only variables that this makes any sense
  627.       on are integers and maybe characters.  In the case of the
  628.       increment operators, the variable is incremented by one, or: 
  629.  
  630.            i = i + 1; 
  631.  
  632.            is the same as 
  633.  
  634.            i++; 
  635.  
  636.            The only difference between the increment and decrement
  637.       operators is that instead of adding one to the variable, one is
  638.       subtracted from the variable.  These operators can be extremely
  639.       useful.  For example, consider the following code fragment: 
  640.  
  641.               int i,j,k;
  642.               i = 1;
  643.               j = i++;
  644.               k = --i;
  645.               printf ("%d  %d  %d\n", i, j, k);
  646.  
  647.            What would be printed on the screen?  The number '1' three
  648.       times.  In this case, the pre-increment and post-decrement
  649.       operators have two stages, the assignment phase and then either
  650.       the increment or decrement phase.  Initially the variable 'i' is
  651.       assigned the value of 1.  The variable 'j' is then assigned
  652.       whatever value is held by the variable 'i', then the variable
  653.       'i' is incremented (notice the plus signs after the variable,
  654.       this is called a post-increment operator).  Then the variable
  655.       'i' is decremented back to 1 by the next line (notice the minus
  656.       signs before the variable, this is called a pre-decrement
  657.       operator), then the variable 'k' is assigned the value of the
  658.       variable 'i'.  There are also pre-increment (++i) and
  659.  
  660.  
  661.       
  662.  
  663.  
  664.       Issue 17                     C News                            12
  665.  
  666.  
  667.       post-decrement operators (i--).  Obviously, you can use any
  668.       legitimate variable that you want.  
  669.  
  670.            Now that we've discussed the increment/decrement operators
  671.       briefly, let's get back to the discussion of this month's
  672.       program.  After the counter is incremented, check to see if it
  673.       is greater than 79, if it is, put a new line out to the file and
  674.       reset the counter to zero, then go back to reading the input
  675.       file.  
  676.  
  677.            The files are usually automatically closed upon exit, but
  678.       to be neat, we will close them manually with the 'fclose'
  679.       function.  
  680.  
  681.            This closes out this edition of my column.  The whole point
  682.       of this column is to demonstrate that a lot of data (in this
  683.       case the data required for file use) can be passed among
  684.       functions with the programmer just having to make allowances for
  685.       it's use, and not be real concerned with how it works.  In next
  686.       months column, we'll discuss file I/O some more and pointers.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.       
  722.  
  723.  
  724.       Issue 17                     C News                            13
  725.  
  726.  
  727.       ================================================================= 
  728.       PEPTO: A SHAREWARE SOURCE CODE COMPRESSOR by Jim Singleton
  729.       ================================================================= 
  730.  
  731.  
  732.  
  733.            Recently, I was listing the new files on the C BBS and
  734.       noticed the following: 
  735.  
  736.          PEPTO1.ARC   14208 08-07-89  Odd Utility of the month!
  737.                                       Compress C Src code for Compiling
  738.  
  739.       I decided to see exactly what this program did that qualified it
  740.       as the "Odd Utility of the month!"  (Not to mention that the
  741.       name of the program was enough to grab my attention.)  I guess
  742.       I've always had a thing for odd and interesting little utilities
  743.       and programs.  So, I went ahead and downloaded PEPTO1.ARC.  
  744.  
  745.            Upon unarchiving PEPTO1.ARC, I found myself with three
  746.       files: 
  747.  
  748.             PEPTO.C,
  749.             PEPTO.EXE, and
  750.             PEPTO.TXT,
  751.  
  752.       the source, executable, and text files for PEPTO.  
  753.  
  754.            What does PEPTO do?  Well, PEPTO is designed to shrink
  755.       source code and header files for C programs.  Why?  To reduce
  756.       space requirements and decrease compile times by compressing the
  757.       system header files.  The author also states that PEPTO can be
  758.       used for distribution of secure copies of source code by
  759.       changing major variable names and compressing the source.  
  760.  
  761.            PEPTO is easy to use.  The commands can be entered on the
  762.       command line individually: 
  763.  
  764.            PEPTO DICE.C, 
  765.  
  766.       using wildcards: 
  767.  
  768.            PEPTO *.H 
  769.  
  770.       There is also a feature, /C, which prevents the lines in the
  771.       source file from being concatenated: 
  772.  
  773.            PEPTO /C HELLO.C 
  774.  
  775.       This last feature can be useful if the C compiler you use does
  776.       not like long command lines.  After a file has been compressed,
  777.       the compressed version has the extension *.PEP.  
  778.  
  779.  
  780.  
  781.       
  782.  
  783.  
  784.       Issue 17                     C News                            14
  785.  
  786.  
  787.            What does a program that has been compressed with PEPTO
  788.       look like?  The file PEP.LZH, included with this issue of the  C
  789.       News, gives a couple of examples.  The program DICE.C, which was
  790.       used in the command line parameters article was compressed form
  791.       1,768 bytes to 433 bytes.  The compressed file, DICE.PEP, can be
  792.       compared to the original file, DICE.C.  With a small program
  793.       like this, it is easy to look at the compressed version and see
  794.       what the program is supposed to do; however, in a larger, more
  795.       complex, program it is not as easy.  For example, I took the
  796.       program PROGRAM8.C, which I happened to have handy and
  797.       compressed it with PEPTO.  The resulting file is just under half
  798.       as large as the original, not the 75.5% reduction I'd seen with
  799.       DICE.C, but DICE.C was mainly comments.  (NOTE:  Just stripping
  800.       the comments and left justifying the code in DICE.C produces a
  801.       file of 533 bytes.)  PROGRAM8.PEP is hard to read because not
  802.       only are the comments missing, but there is no real structure to
  803.       the program.  
  804.  
  805.            Like the file description said, this an odd utility.  As
  806.       with any program, there are a couple of things to remember when
  807.       using PEPTO.  PEPTO will not accept *.PEP files as input.  PEPTO
  808.       only understands inline assembler lines which begin with "asm",
  809.       don't use a command such as "#define A asm".  
  810.  
  811.            The author, "created it for my own use (necessity is a
  812.       mother!) but it is something which can benefit others so I have
  813.       decided to release it as shareware."  As such, a five dollar
  814.       donation is requested if you find PEPTO useful.  
  815.  
  816.            More information on PEPTO can be obtained from the author: 
  817.  
  818.                David Stafford
  819.                Research and Development
  820.                1800 Green Hills Rd.
  821.                Scotts Valley, CA 95066
  822.  
  823.                CIS: 72411,2670
  824.                MCI mail: DSTAFFORD.
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.       
  842.  
  843.  
  844.       Issue 17                     C News                            15
  845.  
  846.  
  847.       ================================================================= 
  848.       ARTICLE SUBMISSION STANDARDS      
  849.       ================================================================= 
  850.  
  851.  
  852.  
  853.  
  854.            All articles, reviews and letters to editor should be
  855.       submitted in a ASCII formatted file.  Please use 0-65 margins,
  856.       and single space.  Do not format the text in anyway, as I use
  857.       Proff to format C News.  Proff takes care of the justification,
  858.       footnotes and headers.   
  859.  
  860.  
  861.            You can send in your article on a diskette to the C BBS, or
  862.       upload it to the C BBS. See "How to Contact us here at C News"
  863.       for more information.   
  864.  
  865.       Barry 
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.       
  902.  
  903.  
  904.       Issue 17                     C News                            16
  905.  
  906.  
  907.       ================================================================= 
  908.       HOW TO GET HOLD OF US HERE AT CNEWS
  909.       ================================================================= 
  910.  
  911.  
  912.  
  913.  
  914.            The primary address for C News is as follows: 
  915.  
  916.            C News
  917.            % BCL Limited
  918.            P.O. Box 9162
  919.            McLean, VA 22102
  920.            USA
  921.  
  922.            The primary electronic address for C News is the C BBS: 
  923.  
  924.            C BBS
  925.            1-703-644-6478
  926.            2400,8,N,1 23hrs a day.
  927.            1:109/307 in Fidonet.
  928.  
  929.  
  930.            The secondary electronic address for C News is: 
  931.  
  932.            MCI Mail: BCL Limited 
  933.  
  934.  
  935.            Barry 
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.       
  962.  
  963.