Question: Write a C program coding.c that includes a main program and two functions with the following function prototypes: void encodeStr ( char *input, char *output,
Write a C program coding.c that includes a main program and two functions with the following function prototypes:
void encodeStr ( char *input, char *output, CodeT code );
void decodeStr ( char *input, char *output, CodeT code );
The first function takes the input string in input and generates the encoded string using the information in code. The result is stored in output. The second function takes the input string in input and decodes it back using the information in code. The result is stored in output again.
Both functions use the following structure as the key to encode and decode text messages:
typedef struct {
char from[28];
char to[28];
} CodeT;
The main function may then initialize the values as shown below:
CodeT code = { .from = " abcdefghijklmnopqrstuvwxyz",
.to = ".172093%@#+!:_-$^*()854=6?>" };
The main program must prompt the user repeatedly for a line of text and then generate and print the encoded text string before decoding the encoded text string and printing the result again to the screen to test that the original text string can be retrieved through the decoding function. The program should stop prompting the user for input text when the user enters an empty text as input. Use the program discussed in class to read text lines from the keyboard.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
