CSC161 2010F, Class 10: The Command Line Overview: * Command-line basics. * Using the command line. * Lab. Admin: * Sam not here for office hours. Will respond to email (I hope). * Are there questions on assignment 3 * What do ugly characters like Black Diamond mean? * It means that you're dealing with a character outside of 33..127. * Readings for Tomorrow: * A Tutorial on Binary Numbers (link online) * K&R 2.6 and 6.9. * We may not finish today's lab in class. I expect you to finish it on your own. (You need not do the extra problems.) * I returned HW2 before class today. Let me know if you have questions on my comments. We'll talk a bit about a variety of issues. GNU Formatting/Coding Guidelines * Specify return type * If you have a non-void return type, you must use "return" at the end of the function, even in main, and even if K&R don't. * Lots of indenting rules and rules for placement of punctuation. Four score and seven years ago our fathers brought forth on this continent a new nation,conceived in liberty ,and dedicated to the proposition that all men are created equal. C has at least three "formatting standards". * Sam will tell you a bit about processing the command line in C and then we'll do the lab tomorrow. * C and Unix grew up hand in hand * One of the key parts of Unix is that programs take command-line arguments * So C needs a way for the programmer to access those command-line arguments. * Decision in C: Make them parameters to main int main (int argc, char *argv[]) { return 0; } You need not call them argc and argv int main (int fred, char *wilma[]) { return 0; } The integer (argc) parameter is a *count* of the number of arguments the program was called with. The array parameter (argv) is the "argument vector" - an array of strings. If argc is 2, argv[0] and argv[1] are the two arguments. When you type % program foo bar baz Unix/C flils in the argc and argv How will you use the command-line arguments? * Eventually: Just like everyone else: For flags and other inputs * For testing: You can take input from the command line, which is often faster. * q2l 32.2