Computer Science 211b Midterm Examination
7 March 2006
1 hour 40 minutes
Instructions/Notes: The examination has 48 questions on 10 pages, and a total of 137
marks. Put all answers on the question paper.
This is a clos
CS211a - Software Tools and Systems
Exercise Hints to C Programming
For the value of you can use 3.14 instead (or more digits for better precision).
Define as a constant, for instance, 3
One must have an account to use a Unix
To share resources, need to tell users apart.
Username (public) and password (private).
You can only access the resources that are
specified by your account information.
1. Unix account
2. Login: with a terminal or using telnet or ssh
3. Change password
4. Must logout!
5. Emails: (a) mutt (b) pine (c) .forward file
6. Basic commands: who, ls, cat, more, man
Editors in Unix come in
C Traps and Pitfalls*
AT&T Bell Laboratories
Murray Hill, New Jersey 07974
The C language is like a carving knife: simple, sharp, and extremely useful in
skilled hands. Like any sharp tool, C can injure people who dont know how to h
Expression and Operator
Expressions and Operators
3 + 5;
The expressions formed by data and operators
An expression in C usually has a value
except for the function call that returns voi
Brief Unix History
In 1969, Ken Thompson at AT&T Bell Labs
began developing Unix.
First done in assembly language.
Ran on DEC PDP-7 with 8K words of memory.
In 1974, Unix was rewritten in C.
By writing C compilers, Unix
regular expression is a pattern which
matches some regular (predictable) text.
u Regular expressions are used in many
like grep, sed, vi, emacs, awk, .
form of a regular expression:
File Security and Permissions
File Permissions (1)
respect to a particular file, Unix divides the
set of all users on a system into three categories:
v The owner of the file.
v Most of you are in the group 2ndyr
v Used for easier
I/O and Redirection
default place to which programs write
default place from which programs read
default place where errors are reported
demonstrate - cat
Files and Directories
Files and Directories (1)
What is a file?
a container for ordered data
persistent (stays around) and accessible by name
regular Unix files are pretty simple
essentially a sequence of bytes
can access these bytes in orde
A Brief History
Created by Dennis Ritchie at AT&T Labs in 1972
Originally created to design and support the Unix
There are only 27 keywords in the original version of C.
for, goto, if, else
Easy to build a