CSC161 2010F, Class 32: Pause for Breath (2) Overview: * HW6 * Exam 2 Admin: * EC: Cool talk this Thursday. Martin Dluhos on something. * Cool CSC 397 independent study next semester. "Programming for the Common Good" (Ruby, Rails, GIT, and then work on Diaspora) Disapora is buzzword buzzword buzzword, which facilitates buzzword and buzzword. joindiaspora.org or freenetworkmovement.org * Cool play tonight, convo tomorrow, eighteen-wheeler on Friday. * We may have propsies on Friday. Yay! * Reading for Friday: K&R 5.5 and Appendix B. * Are there questions on Assignment 6? * Distributed: Exam 2. Exam 2 * Discussed HW 6 * What are your unit tests for is_fib? * Generate fib(n) for various values of n and make sure that the answer is true. (Systematically) * Negative numbers. Make sure those are not Fibonacci numbers. * INT_MAX. We don't think it's a Fibonacci number * INT_MIN. * fib(n) + 1 for n > 4 * Header files are confusing. What can I put into a header file? * Any C code you want. * Predeclarations * Variable declarations * Macros. * Code (not a great idea) * Implementations of functions * Just lines of code * Comments * How do you predeclare a function RETURN_TYPE NAME (PARAMETERS); * Don't foget the semicolon (or the r in forget) * Can you declare global variables in a header file? * Yes, it seems so. * Can you talk for a moment about static, constant, extern, and more * extern: This variable exists, but is declared in another file that I expect to be linked with this one. * static (and global): This variable should only be accessible within this file. * static (and local): Don't reallocate this variable upon recursive calls. * constant (parameters): This function does not change this parameter * For #define, If it's more than one line, what do I do? Put a backslash at the end of every line but the last one. #define foo(x) x + \ x-1 * Should we format it the way we normally format it. * Yes, if you're willing * What should TEST_FINISHED() do? Something like if (errors) printf ("%d errors encountered.\n"); else printf ("You rock!\n"); return errors; * What does the pound sign in front of the variable do? * Says "Make this a string!" * Do we need to include in our headers that use functiosn from ? * If you're confident that the other things that include your header will include , then no. * But it doesn't hurt to do so.