I hearby declare that there shall be no panicking over project 3.
Tackle each small piece separately. Iteratively, add little pieces
and test your code. If you do it in small pieces (Professor Harvey
says to add only 5 lines at a time!), implementing and debugging will
Possible starting points:
Write a program to search a sorted dictionary. (This will require
slightly changing your binary search from lab 11... See below.)
Write a program to read in a gnuplot data file and print out the exact same file.
Write a program to accept the required command-line arguments.
(Handle the cases when the user puts in too few or too many
Write a program to read in a message from input.
After you complete one of these small programs, it may be easier for
you to add a debugging system. Then, you can reuse that system in
your other programs.
Keep chunking the project into small, managable pieces and then add
on another small piece. Trust me: the trick is keeping it small!
Are we supposed to randomly make up any message to put in the
dictionary file, and then compare the keyboard input to that file?
I am unclear about what you are looking for.
Professor Harvey will be giving you a list of words in a dictionary
file. Meanwhile, you can make your own, very short, alphabetized
How do we make main able to take 2 different sets of
The arguments are passed in with argc and argv, as usual. From
argc, you'll know how many arguments were passed in.
Do we need to make a dictionary file ourselves?
Just write a small dictionary file. Professor Harvey will give you a
bigger dictionary file later.
Does the program need to consider punctuation marks?
How do we do a binary search on words?
Binary search on words in not that different from searching for
integers. The only difference is how you compare the words. For
integers, you did a check that said if( key is smaller than data[mid]) //
search the lower half.
For strings, you need to do something similar that says "is this
string earlier alphabetically than the other string", but you can't
just compare two strings using < and
>. Am I being cryptic? I can't say anything more
except for one more hint: use a string function that we used in lab 9.
Do we need to sort the dictionary?
No, your dictionary will be in sorted order. (To make it easier on
yourself, your own small dictionary should be sorted as well.)
Do we want to put everything in a single file that will print the
whole message at once? I thought we were supposed to print one letter
at a time.
You're printing one letter at a time into one file. The point is that
you'll read in one gnuplot file, process it, and print it to the file
before opening the next gnuplot letter file. (It's different in the A
To open the file, I want to use the first character in message
(message), but fopen requires a string. How do I
You're on the right track... What you have is a character, but
you need to give fopen a string. What is a string (in terms of
datatypes)? How could you convert the character into a string?
What should we do about spaces in our message? I mean, can we
make a blank data file for " ", and save it as " "?
When I see a space in the message, I would probably just increment my
shift value and move on to the next letter.
What should we do if the user doesn't enter any arguments on the command-line?
Print an appropriate error message, explaining correct program usage.
I don't understand what you want to see for debugging.
Throughout the program, you'll do stuff like if( debug >=
DEBUG_LEVEL_N), where debug came from the command-line and
DEBUG_LEVEL_N is one of several constants you defined. Depending on
the level, you'll decide how much to print out.
How to shift these letters is eluding me. Do i have to read in every
single character check it to see if its a number, transfer it to
another array and change it back?
You need to read the first coordinate in a row. How do you (as a
human) know when the coordinate stops? How would you tell the
computer to do that? You need to print out the new coordinate. If
you put it in an array or if you print it out directly is up to you.
You want to tell the user where you are in main (if you've read the
dictionary, when you're done loading the dictionary, when you're
processing the message, etc.) You should print all parameters to
arguments that make sense. In the "highest" debug level, you shoudl
have progress messages inside of functions. These messages are for
your benefit--so that you know exactly when a seg fault occurs, etc.
How many and what files should we submit on webct for project 3?
Basically, all of them except for your letters data files. Your .c
program, at least one full example of gnuplot (including the commands
file and the output data file you generated from your C program and
the output png file), and your script file. You should also say where
your Web page can be found. (I would guess that it's
What level of debugging do you wnat in our output?
Level 1 is probably good enough, if you have your code mostly working.
The debugging code is mostly for your benefit during development, but
it also helps me to see how you were debugging your code and thinking
about the program.