Question: How does one implement this function in C++: Create a function that accepts a variable of type char that perserves only strings that start with

How does one implement this function in C++:

Create a function that accepts a variable of type char that perserves only strings that start with that certain variable, while removing any others.

The function can be named: void preserve_string_with_character(char c) [c is a passed letter]

For instance, if a string array (of size 5) includes {"dance", "chance", "boy", "dip", "Donkey"}, then after passing a char 'd', what's left will be {"dance", "dip"}. Notice that "Donkey" is not included because the function is case-sensitive so only lower-case 'd' would work.

Also, the order of the strings after calling this function should be the same like how it was before calling it.

If none of the strings start with the passed letter, or the string array is empty, then the string array is empty after calling preserve_string_with_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!