CEG 2170L -05 Project 3:
Implementing a Substitution Cypher with an Array of
November 06, 2017
In this project we will create a look-up table in the form of
an array of structures and use it to encrypt messages into
numeric-codes and decrypt numeric codes into human-readable
1. Prompt the user for a text filename. Read the contents of
the file into an array of structures. The file will contain
up to 90 records, each record containing a character and
a number. The file containing the conversion codes is
provided. Following shows its contents:
Assume each character corresponds to a number with
exactly two decimal digits (10 <= number <= 99), and
each two-digit number corresponds to a unique character.
Saved to Dropbox • Nov 8, 2017 at 10@21 AM
2. Read the contents of the conversion file to an array of
3. Print out the following USAGE message to the screen.
Then print “Enter Command:” to the screen and wait for
Command to encrypt a message to a numeric code:
Command to decrypt a numeric code to a readable
decrypt < number-code>
To Exit program, enter quit or q.
4. If user input starts with encrypt (or e), convert each
alphabet in the <sentence> to the two-digit number
associated with it in the array. Print the encrypted
numeric code to the screen.
5. If user input starts with decrypt (or d), convert every
two numeric digits to a character and print it to the
6. If user input is quit (or q) exit the program.
7. For any other input, print an appropriate error message.
• Examples of user input are:
What is 3 times 10?
What is three times ten?
• The <number-code> in a decrypt input should have an
even number of digits. Following are valid <numbercode> inputs:
199694463258 (Nov. 6)
• Input is case sensitive
• The program encrypts characters (numbers, symbols, and
lower- and upper-case letters).
• If the program cannot find the correspondence to an input
character during encrypting, an appropriate error
message should be printed out. If the program cannot
find the correspondence to a two-digit number during
decrypting, again it should print an appropriate message.
• Make sure to read all characters on an input line,
including spaces and symbols.
Example: encrypt CEG 217-0 class
• Name your program LastName_FirstName_Project3.c
and upload it to the Dropbox under Project 3 no later
than 2:00 pm on November 13.