Lecture Summaries - Week 7
Jump To:
[Lecture Index |
Previous Week's Lectures |
Next Week's Lectures]
Topics covered:
- How input and output redirection works and why it's important.
- How we can also do character I/O with
getchar and putchar.
- What character-at-a-time input-reading loops look like with
getchar.
- A program to echo its input
(display.c,
page 74).
- Many useful programs are simple variants use character-at-a-time
input reading loops.
- A program to count its input characters
(charcnt.c).
- A program to count its input lines
(linecnt.c).
- How can we use state diagrams to help us implement more complex
character-at-a-time processing.
- A program to count its input words
(wordcnt.c).
- There are a collection of useful character testing functions
in ctype.h.
Reading: Chapter 4.3, 4.4 (pages 73-79).
Topics covered:
- Why we write functions to handle high-level input tasks,
such as obtaining yes-or-no answers.
- How we use character-at-a-time input to write these functions.
- The yesorno function gets a yes or no answer from the user
(yesorno1.c).
- A main program that uses yesorno
(useyn1.c).
- Why we have to worry about the carriage return when obtaining input.
- A main program that uses yesorno,
where it is clear it doesn't work
(useyn2.c).
- How to skip characters until the end of the line.
- Fixing yesorno to do this
(yesorno.c,
page 79).
- How to skip blanks before our input.
- How to allow multi-case input with tolower and toupper.
- Combining these new features.
- Extending yesorno to allow leading blanks and upper- or
lower-case answers
(yesorno2.c).
- Some shortcuts in using functions.
- Using return values directly (as in yesorno2.c).
- How expressions in ifs and loops are automatically
compared against zero.
- Some things to think about when using functions.
- Watching out for the assumptions we made when we implement a function.
- Testing a function to locate those assumptions.
Reading: (No new reading for this lecture)
Topics covered:
- How scanf converts "character" numbers to integers.
- A review of C's arithmetic operators.
- What happens when we do arithmetic on characters.
- A review of C's relational operators.
- How relational operators return 0 or 1.
- The logical operators (and, or, and not).
- How to understand the behavior of logical operators with
truth tables.
Reading: Chapter 5.1-5.3 (pages 91 - 100)
[EE150 Home Page |
Top Of Page]