Question: Create a file named caesar.cpp . In this file, write a program that implements a Caesar cipher. Your program should expect two command line arguments.
Create a file named caesar.cpp In this file, write a program that implements a Caesar cipher.
Your program should expect two command line arguments. The first argument must be either e for encryption or d for decryption The second argument must be a nonnegative integer. If the user provides the wrong number of command line arguments, if the first argument is not expected, or if the second argument is not composed entirely of the digits through print a usage message and exit with exit code to indicate that there was an error:
julius@gallia lab$ caesar
USAGE: caesar edkey
If the user provides valid command line arguments, your program should read its standard input one line at a time. It should then either encrypt or decrypt the line and print the result. When encrypting, all English letters a through z and A through Z should be "rotated right" by the usersupplied key an a rotated right would become a d and a y rotated right by would become a b Capitalization should be preserved, and all nonletter characters should be left unchanged.
julius@gallia lab$ caesar e
abcdefghijklmnopqrstuvwxyz
defghijklmnopqrstuvwxyzabc
Veni, vidi, vici.
Yhql ylgl ylfl
When decrypting, all letters should be rotated left.
julius@gallia lab$ caesar d Frtw Anshny Trsnf Amor Vincit Omnia
The key may be greater than twentysix. Note that when the key is a multiple of the input should be unchanged.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
