CSC 161 | Grinnell College | Spring, 2015 |
Imperative Problem Solving and Data Structures | ||
The purpose of this module is to smoothly integrate and review material that has been presented through the semester, with a particular emphasis on C programming concepts and full usage of the Scribbler robot.
Day | Topic | Preparation | In-class | Due Date | Availability for Extra Credit |
---|---|---|---|---|---|
Wednesday, April 29 | Command-Line Arguments |
| lab exercise
| ||
Friday, May 1 | Files |
| lab exercise | ||
Monday, May 4 | Files Continued |
| lab exercise | extra credit if submitted by Friday, May 8 | |
Tuesday, May 5 | Supplemental Problem 5 | Supplemental Problem 5 (done individually) | Tuesday, May 5 | ||
Tuesday, May 5 | Project Day 1 | project | Friday, May 8 | ||
Wednesday, May 6 | Project Day 2 | project | Friday, May 8 |
Write a "robot logger" program which can log actions to a file, and also read actions from a file and performs them.
if the use specifies a command-line directive -w, then
if the use specifies a command-line directive -r, then
it should be possible for a user to utilize both -w and -r mode.
This program should support at least 10 different actions (following the module 011 project command requirements). As with the Module 011 project, each action (except, perhaps, quit) must be implemented as a separate procedure.
The following examples are based on a program proj111 that supports this project. Although this table shows several possibilities, the table is not complete. For example, various combinations of -r and -w are possible, with and without file names, and the -r and -w flags could be in either order.
Command line | Interpretation |
---|---|
proj111 | no command-line arguments, so reads from terminal and writes to terminal |
proj111 -r infile.dat | reads commands from file infile.dat; writes to terminal |
proj111 -r | reads from a file; since filename not given on the command line, program must ask user what file to use; program writes to terminal |
proj111 -w logfile.dat | reads from terminal; writes commands with parameters to file logfile.dat |
proj111 -w | reads from terminal; writes commands with parameters to a file; since file name not given on command line, program must ask what file to use |
proj111 -w logfile.dat -r infile.dat
OR proj111 -r infile.dat -w logfile.dat | reads commands from infile.dat, writes commands with parameters to infile.dat |
proj111 -r infile -w | reads commands from infile.dat; writes comands with parameters to a file; since log file name not specified, user must be asked for the filename |
Global variables may not be used in this project. Use parameters to communication data into procedures.
You are encouraged to use either your module 011 project or your command-robot.c program as the basis for the command input.
One approach would involve two variables readMode and writeMode.