Introduction
Announcements

Schedule
Labs
Assignments
TA office hours

Tests, exam

Topic videos
Some course notes
Extra problems
Lecture recordings

Discussion board

Grades so far

Assignment two questions and answers

Here are some questions and answers about assignment two, and other notes. Suggestions for additions to this list are welcome (e.g. via e-mail).

Click on the highlighted text to expand an item. [EXPAND ALL]


Most of all, remember to "Keep It Simple". |+|
Some resources: |+|
More general advice: |+|
Don't type "vigenere cipher in C" into Google. |+|
In general, don't check whether operations will succeed; |+|
The assignment handout does not necessarily specify all of the details of the required behaviour of your programs in all cases. |+|
I am happy to interpret compiler error messages (for CSC 209 students). |+|
Q: When I compile my program (any one of the three) I get the following warning |+|
Standard indentation is required in your C programs. |+|
Your program must not exceed array bounds no matter what the user input (or command-line arguments). |+|
Q: Can I put some functions in a separate .c file and submit that too? |+|
Q: How do you print to the standard error? |+|
Q: If one of the files or directories specified on the command line cannot be opened, should we exit immediately or |+|
The return type of getchar() and getc() is int, not char, and you can't store it in a char variable. |+|
Q: What is the difference between using fopen(), getc() or fgets() or fscanf(), then fclose(); as opposed to using open(), read(), and close()? |+|
C's "sizeof" operator does not give you the size of an array, in general. |+|
Q: Various segfault or bus error problems ("Segmentation exception" or "Bus error"). |+|
Various getopt() questions: |+|
Q: "findempty" takes no command-line options. So if the user does "./findempty −q", is that an error? |+|
Q: In crypt, do we need to deal with the special case of a command-line argument of "−"? |+|
Q: Do we need to include comments in our code? |+|
crypt always outputs to stdout, whether its input is from stdin or from one or more files whose names are specified on the command line. |+|
Assuming maximum path lengths: |+|
Q: Does crypt have to store the entire input file so as to be able to |+|
Q: How does crypt detect whether its standard input is a file or a terminal? |+|
An example of reading a directory with opendir() / readdir() / closedir() |+|
Q: What is a DIR* ? (the return value from opendir()) |+|
Q: What's the difference between stat() and lstat()? |+|
Q: Why do you have to skip "." and ".." in the findempty recursion? |+|
Q: What should the exit statuses of all of the programs be? What's 0, 1, and 2? |+|
Note the two options for how you interpret the command-line key in crypt: |+|
Q: What does it mean that "a chdir() in processing the first directory may invalidate |+|
Q: Why am I not allowed to use ftw() or fts() to write findempty? |+|
Q: Should I use realpath() or getcwd() to find the path name for a directory/file? |+|