CSC161 2010F, Class 07: Basic Input and Output in C Overview: * I/O Basics. * A Group Exercise. * Lab! Admin: * Notes on Web site * Are there questions on assignment 2? * Is #13 really as much of a beast as it seems to be? * Identify when you've hit the end of a word. (Steal from book. Cite.) * Keep track of how many characters are in a word. (May be in the book. Otherwise: Counter variable. Set to 1 when you begin a word. Increment at each character.) * Keep the histogram: An array of size 10 or 11, depending on what you find easier. Alternately: 10 variables. * Print the histogram in rows: For loop * Note that the due date was changed until Thurday. * I had a request to go a bit slower on how you compile, and I will do so. * I expect to grade assignment 1 tonight. * For tomorrow: Read K&R 5.10 (The Command Line) Input and output in C * Taken from the library * printf for writing stuff printf (FORMATTING INSTRUCTIONS, stuff, more stuff, even more stuff) * Each bit of stuff gets plugged in in order. * A percent sign indicates that you want to plug in something * The stuff after the percent sign indicates the type and other issues. printf ("Your grade is %d.", yourgrade); printf ("Your grade is %3d.", yourgrade); printf ("Your grade is %03d.", yourgrade); * scanf for reading stuff scanf (FORMAT INSTRUCTIONS, stuff, more stuff, even more stuff); * Each bit of stuff gets filled in in order. * A percent sign indicates that you want to fill in something * The stuff after the percent sign indicates the kind of thing you want to read. * Precede each variable by an ampersand (for reasons we'll cover later). scanf ("%d", &grade); scanf ("%1d", &grade); scanf ("%1d%1d%1d", &a, &b, &c); * putchar to write individual characters/bytes * getchar to read individual characters/bytes * How would you find out more about printf man 3 printf Look in the dead tree volume which is carefully hidden under a pile of papers in Sam's office (or maybe lab)