Written by Chris Gregg
Welcome to the assignment advice/FAQ page!
The assignment writeup is the place to go for the formalities (required specifications, due date, grading standards, logistics, and so on). This is the companion advice page where we offer hints and recommendations and answer common questions. You may want to skim this page now to get a sense of what's covered and return here on an as-needed basis for further review when/if these issues arise.
Consider this page a work-in-progress-- we will update to include common questions that arise on the forum and in office hours.
Common questions about assign0
Why do I have to learn Linux? What's wrong with an IDE such as Eclipse or Qt Creator?
CS107 is a "systems" course, meaning that we will delve under the hood to relatively low-level programming. Systems is one of the tracks for a CS major at Stanford, and people who work in the systems branch of computer science spend a whole lot of time with a command prompt. We want you to be comfortable with Unix/Linux, as you will invariably see it again at some point in your CS career, even if you don't focus on the systems track. Certainly, some of the command-line tools we use in cs107 are available in various IDEs, but not all of them are in one nice package, nor available for multiple operating systems. Think of your Linux abilities as one more skill to add to your growing computer science toolkit.
Do I need to memorize all of the information on the Unix Reference page?
No. You will start to memorize lots of the commands just by repetition, but you do need to get a good head-start on the process by reading the information and/or watching the videos. Familiarization with the command line will simply speed up your ability to get work done in the course, and lead to less frustration.
vim or emacs?
See Editor Wars on
Wikipedia. We don't want to get mired in the argument, but we'll
just say that vim is better and emacs is better. We are, however, pushing
for your editor to be unix-native. Read more of our advice on choosing an editor.
What happens if I get disconnected from ssh while I am working? Do I lose all my work?
First: save early and often. You will potentially lose any work up to
the last time you saved. Second: there are a number of ways to connect so that
you do not lose your work. You can look up the screen program,
which allows you to connect to the myth computers and to re-connect
into the same place where you left off after a disconnect. If you are using
the vim editor, you can try to open the file and hit "r" to recover from
the "swap file," which might have more of your
work. This is sometimes successful (you can also just (d)elete the swap
file if you know it is not useful).
When I try to run the triangle program in my directory, it responds "command not found". What's wrong?
Unix wants you to instead refer to the program by its full name ./triangle. A longer explanation of this issue and how to enable use of the short name can be found in our common questions about unix.
Do we have to handle case where the user's argument to triangle is not a valid integer?
No. Sadly, atoi is little help in this case. It is only capable of converting a string that is a well-formed number whose value is in the range of signed int. You can assume that the user's argument will comply. The only error-checking you need is to reject integers that are not a good number of levels for the triangle. Soon we will learn about more robust conversion routines.
What is the recommended way to handle a fatal error?
Print an informative error message and halt the program by calling exit(1). The non-standard convenience function error() combines print with exit if you'd rather (read its man page for info).
Must my error messages exactly match the wording of the sample solution?
An error message must be accurate and actionable, giving the user sufficient information to understand the problem and what is needed to resolve it. Our sample executable models appropriate handling and feedback on errors. You are not required to match our wording, but any substitution should be similarly informative. Sanitycheck has no human judgment so it will only accept an exact match. When grading, the TA makes the call on whether the mismatch is an acceptable substitution. A reliable way to ensure your error message is sufficient is to adopt the wording of the sample solution.
How do I use the sample executable? How does it relate to sanity check?
Our provided sample executable can be used a reference implementation during testing. Run the solution and your program on the same input and verify the output is the same:
myth> samples/triangle_soln 4
... solution output is here ...
myth> ./triangle 4
... your output is here ...
If your program produces the same result as the sample, all is good. You can manually "eyeball" the two results, or pipe the result into files to be compared with a tool such as diff. A manual comparison becomes tedious as you have more/larger tests, so we wrote the sanity check tool to help. It automates the process of running a command once on the sample and again on your program, compares the two results, and reports match/mismatch. Read our guide on how to use sanity check.