Sams Teach Yourself C in 21 Days

(singke) #1

TYPE& RUN 4 Secret Messages


This is the fourth Type & Run section. Remember, the purpose of the listings in
the Type & Run sections is to give you something a little more functional than
what you are getting in the daily lessons. This listing contains many elements
you have already learned. It also contains a few that you will learn in later
lessons. This includes using disk files which you will learn about on Day 16.
The following program enables you to code or decode secret messages. When
you run this program, you need to include two command-line parameters:
coder filename action
Thefilenameis either the name of the file you are creating to hold the new
secret message or the name of a file that contains a secret message to be decod-
ed. The actionis either Dfor decode a secret message or Cfor encode a secret
message. If you run the program without passing any parameters, you are given
instructions on how to enter the correct parameters.
Because the program codes and decodes, you can give a copy to your friends or
associates. You can then code a secret message and send it to them. Using the
same program, they will be able to decode it. People without the program won’t
know what the message in the file says!

20 448201x-T&R4 8/13/02 11:12 AM Page 305

Free download pdf