Question: Exercise 2 The shortcoming of the code in the previous exercise is that backspace is considered its own character as well! Since it has its

Exercise 2
The shortcoming of the code in the previous exercise is that backspace is considered its own character as well! Since it has its own ascii value (Remember, almost every single key you can press on your keyboard has an ascii value associated with it!), the backspace key will take its own address in memory, considering it is not a newline! This sets up our objective for this exercise : Ex 2 Q1. How do we get the backspace key to work as we typically expect it to work?
We want to ensure that backspaces will not affect the results of our palindrome checker.
Our palindrome checker is actually perfect! The real issue here has to do with the way we take in input. For this exercise, you will be modifying your SUB_GET_STRING subroutine to correctly handle backspaces. Do you remember how to recognize your sentinel character? The backspace character is no different than any other character; when you type it in, it is recognized based on its ascii value.
Instead of putting the backspace into your array like all other characters, you will now have to handle backspaces differently. Rather than adding a new character into the array, you should remove the character at the previous index in the array. When you take the backspace character, make sure to place the value of 0 at that location in memory so you can effectively backspace the previous character.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!