Question: Write a program that prompts the user to enter the name of a file. The program encodes sentences in the file and writes the encoded
Write a program that prompts the user to enter the name of a file. The program encodes sentences in the file and writes the encoded sentences to the output file.
Enter the file name: messages.txt Output: encoded words are written to file: messages.txt.swt
The program reads the content of the file and encodes a sentence by switching every alphabetical letter (lower case or upper case) with alphabetical position i, with the letter with alphabetical position 25 i. For example, letter a is at position 0 and after encoding it becomes letter z (position 25). Letter m is at position 12, it becomes letter n (position 13) after encoding because 25 12 is 13.
1) The program should begin with a comment that briefly summarizes what it does. Also, Information to include in the comment for a function: name of the function, purpose of the function, meaning of each parameter, description of return value (if any), description of side effects (if any, such as modifying external variables)
2) Name your program file_encode.c. The output file name should be the same name as the input file but with an added extension of .swt. For example, if the original file name is abc.txt, the output file name is then abc.txt.swt. Assume the file name is no more than 100 characters. Assume the length of each line in the input file is no more than 100 characters. Assume the input file contains no more than 1000 lines.
3) In the program, you should include the following function.
void line_switch(char *s1, char *s2); The function expects s1 to point to a string containing the input as a string and stores the output to the string pointed by s2.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
