Create a program called copy text that takes two command line arguments: the first argument is the name of the file to be copied:

computer science

Description

L3.1 (5 marks)

Create a program called copy text that takes two command line arguments: the first argument is the name of the file to be copied: the second argument is the name of the new file. If the second argument is missing, copy the file to stdout. If both arguments are missing. the program should read from stdin and print to stdout.

Example: copy_text original. txt thecopy. txt


L3.2 (5 marks)

The most common of the Caesar Ciphers still in use is Rotl3. which uses a shift of 13. Write a program that takes in input from a file and prints it into a new file encoded using Roti 3. Only Roti 3 letters, leave digits, white space and punctuation unchanged. The file names should be conunand line arguments as specified for the copy_text program froni Question 1. Name this program rotl3.c



L3.3 (10 marks)

Encode a message from a file using the Caesar Cipher with a shift as entered as a command line argument. The results should be placed in a new file. If the shift is O, the program should just produce a copy of the file (similar behavior as question 1). The program should accept positive and negative shift values (positive shifts add the absolute shift amount: negative shifts subtract the absolute shift amount). Ifa command line argument is entered that is not a number. or is a number whose absolute value is greater than or equal to 26. print an appropriate enor message to the screen: but do not create a new file (use fprintf(stderr, “%s\n’, ycur message” to accomplish this).


The program should take in a three command line arguments:

Instruction Files
Image12.PNG
108.4 KB

Related Questions in computer science category