Question
Having trouble with this problem. Please use template. Thank you!! /Problem: to write (and test) a function that has a //partially filled array of characters
Having trouble with this problem. Please use template. Thank you!!
/Problem: to write (and test) a function that has a //partially filled array of characters as a formal parameter. //A partially filled array requires two parameters, the array //itself and a size parameter. The function deletes all //repeated letters from the array, and close up the 'empty' //positions, then decrease the size parameter. //Test this function.
//The main program generates test data.
#include
//modifies array to delete all instances of any duplicates //of characters found in array void deleteRepeats( char array[], int& size );
//returns number of characters up to the null terminator, \0 int length( char array[]);
int main() { using namespace std; char array[81] = "mary had a little lamb. its fleece was white as snow."; cout << array << endl; int size; size = length(array); cout << "size = " << size << endl;
deleteRepeats( array, size);
cout << "reduced array = " << array << endl; cout << "reduced array size = " << size << endl;
char array1[81] ="Now is the time for all good men to come to the aid of the country.";
cout << array1 << endl; size = length(array1); cout << "size = " << size << endl;
deleteRepeats( array1, size);
cout << "reduced array = " << array1 << endl; cout << "reduced array size = " << size << endl; }
void deleteRepeats( char array[], int& size ) { //complete the function }
int length( char array[]) { //complete the function //strings are terminated by a \0 //length is the position of '\0' }
Step 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