Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description A Caesar cipher (http://en.wikipedia.org/wiki/Caesar_cipher) is a simple cryptographic technique in which each letter is the original message is shifted to a different letter which

Description

A Caesar cipher (http://en.wikipedia.org/wiki/Caesar_cipher) is a simple cryptographic technique in which each letter is the original message is shifted to a different letter which is located at a uniform offset in alphabetical order. For example, the message Hello World! and offset 3 would result in an encrypted message Khoor Zruog! The message Dogs and Cats and offset -2 (which is equivalent to an offset of 24) would result in an encrypted message Bmeq ylb Ayrq. Note that only alphabetic characters are shifted, and that the case of the letter is preserved.

Functional requirements

Write a Unix program that takes 3 inputs from the command line: the pathname of an existing input file, the pathname of an output file to be created, and an offset between -25 and 25, inclusive. If the input file doesnt exist, or if the output file cannot be created (perhaps because directories in its path do not exist, or because you dont have permission to create files in the given location), or if the offset is out of range, the program prints an error message to standard error and immediately ends. Otherwise it uses the input file and offset to create an encoded output file using the Caesar cipher as described above.

Nonfunctional requirements

Implement a function, char caesar(char s, int n) which converts a letter according to the rule given above with offset n. To avoid strange arithmetic errors use n%26 for the offset. They new char is returned. If the character is not a letter s is returned, unchanged. Use this function to process the entire file.

All the functions you write (including caesar) should be in a file caesar.c, with corresponding .h file. Main should be in its own .c file.

You may use the functions from string.h. To convert the 3rd command line argument from a string to an int, use the strtol or atoi functions from stdlib.h http://www.cplusplus.com/reference/clibrary/cstdlib/atoi/ http://www.cplusplus.com/reference/cstdlib/strtol/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

Students also viewed these Databases questions