Question
Using pointers write a function called removeChar that will remove each instance of a specified character from a CString. A CString is defined as an
Using pointers write a function called removeChar that will remove each instance of a specified character from a CString.
A CString is defined as an array of characters that is terminated by the NULL ('\0') character.
Your function should return the number of characters that were removed from the string.
Your function should take as arguments, the CString to remove the characters from, and the character to remove.
Note:
The argument which represents the character to be removed should be a default argument. Meaning that if a character is not provided it will default to the space character (Decimal 32 or Hex 20).
Using the subscript operator [] is not using a pointer.
What not to do
Using any of the following will drop your grade for this assignment by 70%
global variables.
cin in any funciton other than main
cout in any funciton other than main
goto statements
Note:
To get a sentence from the keyboard you must use cin.getline:
char str[100];
cin.getline(str, 99); // save room for the null character.
Your output should look something like the following:
C:Windows system32\cmd.exe This is a test i hope it works Enter a character to remove Removed 4 i characters. Your string is now: Ths s a test hope t works Press any key to continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started