CSci 370 Homework #0


Due: Monday, September 11, 2017

This assignment is due at the beginning of class on the due date.  This assignment is worth 16 points.

Reading.  Complete the previously assigned readings in King

Warmup.  Complete the exercise assigned (and possibly begun) in class. This will ensure correct usage of gcc in the next few assignments - don't turn in any program files for this part.

Problems.  You'll want to save, compile and run these programs all in the same directory.

  1. (4 points) Type the attached program File Copying into your favorite editor.  Save it as filecopy.c, then compile as in lab.

    If there are any warnings, make a note of them but keep going.
    If there are any errors, you did something wrong.  Use them to correct your C code.
    If there were only warnings, the program should run in spite of them.  Run it as shown:
    ./filecopy < filecopy.c
    Take a screenshot image of the Terminal window showing the compilation step and results of running the program; save the image to a file.

  2. (4 points) Type in the attached program Character Counting. Call it charcount.c, then compile and run it. 

    Fix any errors and note warnings as in Problem #2.  When the program works, run it twice as shown and record the output:
    ./charcount < filecopy.c
    ./charcount < charcount.c
    Take a screenshot image of the Terminal window showing the compilation step and results of running the program; save the image to a file.

  3. (4 points) C compilers have become better at catching errors over the years. Programs with warnings often run without problem because of defaults that cover the cases for these particular warnings (this has to do with improved standardization of the language).

    Even so, eliminate the warnings in both programs by giving main() an explicit return type of int, and returning a value when the program finishes. The value returned by main is interpreted by the shell as its success code, where 0 is consider success.
     
  4. (4 points) Use what you've learned to create, properly compile, and test the three files making up the Point ADT example from class:  Recall that you don't have to understand the code fully to build and test the program, though you should understand the basic workings of the main function. Take a screenshot image of the Terminal window showing successful compilation and results of your tests.

Deliverables.

  1. Turn in a printout of the source code for the final versions of the first two programs (step 3 only)
  2. Before class, e-mail your screenshots to the instructor as attachments