CSC161 2010F, Class 08: Input and Output, Continued Overview: * Q&A on HW2 * A few notes on HW1 * Review. * Lab. Admin: * You should have received comments on your assignment 1 this morning. Let me know if you did not. * Are there questions on assignment 2? * Note that the due date was changed until Thurday. * I've rearranged the syllabus slightly. I expected such rearrangements, which is why I included so many "Pause for Breath" days. * EC for the Kumail performance tonight. 8pm in the Harris High School Gym room * Read K&R 5.10 (the command line) for Friday. Questions on Assignment 2 * How do I put more than one thing in the consequent or alternate of an if statement? * Put brackets around the body of the consequent or alternate and put semicolons between the different commands. * Why might the following code fail to work? int main () { int size = 10; int stuff[size]; stuff[9] = 2; return 0; } // main () The fix #define SIZE 10 int main () { int stuff[SIZE]; stuff[9] = 2; ;;; if (wordlen > SIZE) { ++stuff[SIZE-1]; } else { ++stuff[wordlen]; } return 0; } // main () A Few Notes on Assignment 1 * Almost no documentation of help. Did you talk to no one? * The 'touch' problem * Applications are commonly stored in /bin * Applications are commonly stored in /usr/bin * I can find things with find - slow * which touch * Why are there two 'touch'es? Is our system just touch? * No, one is a link to the other * The manual sections Review * In C, we typically use scanf to read values and printf to print values. * Scanf does not work the way we expect. It does not return the value read. Rather in shoves the value into a variable we provide as a parameter. * Scanf returns a result: An integer that represents the number of variables it filled in. scanf ("%d%d%d", &a, &b, &c); 0 returned: "Agh, I could not read any numbers." 1 returned: "I read the first number, but not the next two." 2 returned: I read a and b, but not c 3 returned: I read a, b, and c 4 retunred: There has been a break in the space-time continuum * We also did some meta learning: When approaching a new function, one should *play* with it. * We built an amazingly complex program that will soon be the basis of a startup. Our program converts quarts to liters.