Sections 0101, 0102, 0103 and Honors, Fall 1995
Tuesday October 31, 1995
Assigned Reading: 9.2 - 9.3
Handouts (available on-line): none
- A quick look at enumeration types.
- We can use enumerations to represent colors of the
rainbow. Program and
- Enumerations do not have to begin at 0. We can
use red to represent 1 instead of 0, as shown in this
- We can use the typedef facility to make
an new type called rainbow. In this
are declared with type rainbow. Note that
just like the more familiar type int,
rainbow can be the type of return values
and parameters too.
- Characters are similar to enumeration types because their
internal representation is an integer. However, we would like
to think of characters as letters, digits, punctuation marks,
etc, and not as a number. Nevertheless, it is sometimes useful
to use the fact that the letter A is followed by
the letter B, etc. Here's a program
that uses for loops to step through the letters of the alphabet.
- We can list the entire ASCII character set using the following
program. Note that in the
output, not all characters are
printable. Special characters are denoted using the backslash
symbol as done in the following program
and Sample run.
- The standard functions that work with characters are in
the ctype.h interface. The following
UNIX manual pages for ctype.h
describe the purpose of the functions.
- Strings are sequences of characters. We will be using the
strlib.h interface from the course library.
Here's a program that prints out
the user's input in upper case. A modified version of the
program stores the upper case version
of the user's input in a new string. The
sample run shows that the original
string and the new string can be printed out.
Fri Nov 3 16:04:34 EST 1995
Richard Chang, email@example.com