Read chapter 3 in Molay. Download the code from ch3.zip
ls2.c
so that it works correctly when the
name of the directory is given as a command-line argument.
ls2.c
so it handles the suid
,
sgid
, and sticky bits correctly. Read the man pages to
make sure you handle all possible combinations.
ls2.c
to support the -R
option. This option lists the contents of a directory and all
directories below it. See printdir.c
for an example of
recursive directory scan.
ls
program to compute the sum of the sizes
of all the files in the current directory and then the total sum for
all directories below it.
recent
, you might use the command
recent -10 ~to show the files in your home directory modified in the last 10 days.
QtHello2.cpp
.
void MyWidget::paintEvent( QPaintEvent *) { QString s; s.sprintf("Window Size\n(%d x %d)",width(),height()); QPainter p( this ); p.drawText(rect(),AlignCenter,s); }Note that the
QString
class has a member function that
acts like sprintf
, with the output going to the the
QString
object. The program now shows the window size and
updates the value each time the screen is redrawn. Customize the
program by adding your name as a third line, and show a screen shot of
the result.
Bruce Molay, Understanding Unix/Linux Programming,
Pearson Prentice-Hall, 2003. ISBN 0-13-008396-8.
Maintained by John Loomis, last updated 29 Sept 2006