Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ATTENTION!!!: This assignment is for a basic and introductory C++ course. As suc

ID: 3836534 • Letter: A

Question

ATTENTION!!!: This assignment is for a basic and introductory C++ course. As such, please do not use complex or obscure opperations and headers that would typically be used in advanced classes as we have not learned them yet. Use only very simple functions and headers. If you are unsure of whether a technique is too advanced, dont use it. If you can answer the question without using a function, please do so.

"C type" string is implied to mean an array of characters with an end of string mark following the last character.

Write a function called Remove with two parameters. The first is a “C type string”. The second is a single character. The function will search through the string and remove any instances of the single character in the string (case sensitive). That is, if the string is “Bill Slater” and the single character is ‘l’, the changed string will now be “Bi Sater”.

Explanation / Answer

void removeChar(char* words, char remove)
{
    char temp[50];
    int i = 0, j = 0;
    while(words[i] != '')
    {
       if(words[i] != remove)
           temp[j++] = words[i];
       i++;
    }
    temp[j] = '';
    i = 0;
    while(temp[i] != '')
    {
       words[i] = temp[i];
       i++;
    }
    words[i] = '';   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote