Reading in from a file and encoding/decoding

Requirements:
• Name your source file exc.cpp
• You are free to use the string class or C-Strings as you see fit
• You must declare a minimum of two functions, one to encode and another to decode
– You are free to declare more than two, but there must be at least one function that does encoding and at least one function that does decoding

• The message will be read in from a file
– The length of the message is arbitrary
– The message will be on a single line only • The message must be converted to upper case
– ONLY letters should be converted

• You will perform a Caesar shift, the size of which is specified when the program is executed
– The shift can only be a positive integer
– The highest allowable shift is 25
– ONLY letters will be shifted

• You will also perform a two layer rail fence cipher 1
– ALL characters will be transposed

• Options will be provided when the program is executed
– The order of the options may be assumed to always be the same
– The first is always encode/decode (-e/-d), the second is the size of the shift, and the final option is the name of the file to be read

• The input file will be overwritten
– This means that when the original message is encoded, there will be no copy of it left
– That file will contain only the encoded message when the program is finished executing
– The reverse is true for decoding

• A sample run of your program that encodes a file named message using a shift of 7should look like:
$ ./extra -e 7 message
$
• The following demonstrate what the contents of the file message would be before and after executing the program (NOTE: This file only contains a single line, it had to be split in order to fit on the page)

– Before:
That which is clearly known hath less terror than that which is
but hinted at and guessed.
– After:
AH OJ ZJLYFRVUOA LZAYV OUAH OJ ZIAOUL AHKNLZKOADPOP SHS UD HOSZ
LYYAH OADPOP B PAKH U BZL.

• A sample run of your program that decodes a file named message using a shift of 7should look like:
$ ./extra -d 7 message
$

• The following demonstrate what the contents of the file message would be before and after executing the program (NOTE: This file only contains a single line, it had to be split in order to fit on the page)

– Before:
AH OJ ZJLYFRVUOA LZAYV OUAH OJ ZIAOUL AHKNLZKOADPOP SHS UD HOSZ
LYYAH OADPOP B PAKH U BZL.
– After:
THAT WHICH IS CLEARLY KNOWN HATH LESS TERROR THAN THAT WHICH IS
BUT HINTED AT AND GUESSED.
Sounds interesting, and you've been given everything you're expected to do. You just need to encode those instructions in C++.

If you're stuck, there's usually someone to help, but that's kinda different from doing it for you.
Topic archived. No new replies allowed.