Question: Create a program in C that reads two strings of length 5 from the user. The user *must* enter a 5 letter word for both
Create a program in C that reads two strings of length 5 from the user. The user *must* enter a 5 letter word for both or your program should warn them and exit. Assuming the user enters valid input, your program will compare the two strings based on the following conditions: 1. If the character is the same in both strings, print a `*`. 2. If the character is present in the first string, but not in the matching position in the second string, print a `^`. 3. If the character in the first string is not present in the second string, print nothing. Your program should include a function which accepts the following parameters: - `char[]` - The string to compare against (this will be the second string as input earlier). - `char` - The character to compare. - `int` - The position of the character in the first string. The function should return a `char` dependent on the conditions above. **Requirements** - Create a function that accepts the parameters listed above. - Read in two strings of length 5 from the user using `fgets`. - Remove the newline character captured by the input. - Compare the two strings and print the output as described above. Your output should look similar to the example run below. ### Example Runs **Run 1** ``` Enter the first string: hello Enter the second string: world hello ^*^ ``` **Run 2** ``` Enter the first string: class Enter the second string: blank class ** ```
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
