Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help update my program urgent please,Thank you. #include #include int main() { char a[7], s[8], d[8]; //declare variables int i=0; int j=0; printf(

I need help update my program urgent please,Thank you. #include #include int main() { char a[7], s[8], d[8]; //declare variables int i=0; int j=0; printf(" Enter a Cat 1: "); scanf("%s", a); printf(" Enter a Cat 2: "); //display enter cat scanf("%s", s); for(i=0; a[i]!='\0'; i++); //forloop cat { d[i] = a[i]; i++; } for(j=0; s[j]!='\0'; j++); { d[i] = s[j]; i++; } d[i] = '\0'; printf(" I am a Cat ", d); // display result getch(); }

In this assignment, you will be creating an upgrade to the cat command you implemented in assignment 2. Lets call it dog because canines are so obviously better than felines. The features that will be added to this program include:

The ability to specify a command line parameter (-b x ) to change the size of the buffer used with read and write to x.

The ability to specify a command line parameter (-n x ) to change the number of bytes read from each file to ex. (Instead of reading the entire file.)

The ability to specify a command line parameter (-c x ) to change the shift to x when applying a simple Caesar cipher to text within the file (described below).

The ability to specify a command line parameter (-r x ) to specify the shift to x when applying a similar rotation to binary data within the file.

The ability to specify a command line parameter (-x ) to output the data in the file as hexadecimal numbers.

The following functions will be of use to you (read and write are mandatory).

read(2)

write(2)

getopt(3)

Requirements

The main loop should be in your main function in one source code file. The functions that perform the encryption should be found in another file. Their declarations will need to be in a header file so that they can be called from main even though their implementations are in another file.

You must make a Makefile that has rules sufficient to compile your program when a user types make in the same directory as your source code. Only files that have changed or have had their dependencies change should be recompiled.

You must use the system calls read and write to do the input and output for the program.

Obviously, your source code must be well documented. If it is not, there will be a large point penalty. This requirement holds for all assignments, whether this line is in the writeup or not.

Caesar cipher

A Caesar cipher is a very simple method of encrypting data. It involves taking the letters of the input and shifting them upwards alphabetically by a number of letters. This number will be specified as a command line parameter. If the parameter has not been specified, do not perform any shift. If it is, then your output should be shifted by that number of letters. Only letters (uppercase and lowercase) should have any shift applied at all. Leave any other characters alone. You should assume that the files are using the ASCII encoding when writing this

Binary rotation

While the Caesar cipher above was interpreting the bytes that you read as text, changing only the alphabetical charaters, this option should apply to any binary value. The principle is the same, but instead of applying it to A-Z and a-z you apply it to any one-byte binary value from 0-255.

Hexadecimal Representation

All numbers are stored as binary bits on the computer. Each char is one byte, which is 8 bits. When dealing with files that are not meant to be read by a human (binary as opposed to ASCII), it can become convenient to encode the data in a format called hexadecimal. Hexadecimal, the base-16 number system, is useful precisely because it is based on a power of 2 (24 = 16), and so each hexadecimal digit represents 4 bits. Numbers represented as decimal (base-10) do not line up in the same way. Each byte is 8 bits, so it can be written as 2 hexadecimal digits. Your program should be able to output the data in this format (2 hex digits per input byte) whenever the -x command line parameter is enabled. Keep in mind that there will be two characters of output for every character of input in this mode.

What to turn in?

When turning in the assignment, the following files should be included:

The C++ source code file containing your main function.

The C++ source code file containing the functions that implement the features enabled by command line parameters.

A C++ header (.h) file containing the declarations for each of the functions implemented.

A Makefile, The rules should be set up so that only the files that have changed need to be recompiled

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

=+ (d) Even if F has jumps, E[ F(X)] ={ + E, P2[X=x].

Answered: 1 week ago