Exercise 02 - Pointers / Arrays / Strings

Out: Wednesday January 10, 2018
Due: Friday January 12, 2018 by 11:59pm.
Note the unusual due time.


  1. We provide some source that "nearly works," as well as a fully working makefile and a fully working executable. The files are here.

  2. Fix the source. When you're done it should get the same result as the solution executable.

  3. The source is written in somewhat dense C. What it does, though, is prints any command line arguments after having reversed them, and then prints "literal string" reversed. For example, here is a sample run:
    $ ./ex02 one two three four
    'eno'
    'owt'
    'eerht'
    'ruof'
    'gnirts laretil'
    

  4. Note that do not need to write any new lines of code to implement the needed fixes.

  5. It's expected that there will be something in or about the C code that you're not familiar with. Please do not just post to the class forum asking what some statement or C construct means. If you need help, (a) that's okay, it's expected, and (b) please ask the course staff. A post whose answer gives away the essence of the exercise turns it into just typing, rather than learning, for everyone who sees it.

  6. Hand in to the course dropbox:
    • a very brief pdf file indicating what changes you made to the code. You are writing to us, and we know what changes are needed, so brevity is valued over detail.
    • all files needed to build your modified code by saying 'make'
(The following are generic requirements that will appear every exercise. Exactly how pertient they are can vary from one exercise to another.)

Your code must:

  • compile on attu without errors or warnings

  • have no crashes, memory leaks, or memory errors

  • be pretty: the code and its formatting, modularization, variable and function names, and so on, must make us smile rather than cry.

  • be robust: you should think about handling bogus input from the user, and you should handle hard-to-handle cases (if there are any) gracefully.