04 I/O

OK, there were quite a few topics people were interested in. Feel free
to start a new thread if you have questions about another topic.

For this topic, I'm going to suggest excercises of varying degrees of
difficulty. I encourage people to post their solutions and attempted
solutions to these or related excercises when asking questions.

I would especially like it if, when they have solved a problem, people
would post a discussion of the major problems they encountered with
their code.

Simple exercises:

I will include some here for commandline argument processing, since
someone asked for that, even though it isn't really file I/O.

* print the name of your executable (ie print "a.out" if the executable
you compile is named "a.out") Don't cheat and hard-code it in!

* print the values of all the commandline arguments

* print "Hello world" to stdout, stderr and to a file

* Implement your own version of Suzi's excercise from last week -
figure out which notes and coins to give any amount of change in.
Read the amount from standard input.

Intermediate:

* Research buffer overflows. What are they, why are C programs
vulnerable, and what can you do to avoid them? See if you can
identify some vulnerabilities in your own code, and fix them.

http://www-106.ibm.com/developerworks/security/library/overflows/
http://www-106.ibm.com/developerworks/security/library/buffer-defend.html?dwzone=security

Advanced:

* Implement the PBM[1] and PPM[2] graphics file format. Write a
program that converts a PBM file into a PPM file.

* Implement an HTML library that extracts all of the HTML tags from a
file (thanks Kathryn).

* Research data structures used in databases to optimise searching for
data on the disk. Implement one of these data structures (hint
B-trees and related data structures).

[1] http://www.dcs.ed.ac.uk/home/mxr/gfx/2d/PBM.txt
[2] http://www.dcs.ed.ac.uk/home/mxr/gfx/2d/PPM.txt