I am playing around manipulating strings and currently I want to take a full name typed in by a user eg. "Mike W. Heintzman" and then take three letters input by the user, eg. M I E and then I want it to find all of those instances in the name. I have upto this point complete. What I cannot figure out how to do is this next part. I want to take the information from above and delete those characters print out the name without the given letters and then reinsert those letters into their previous position this is the code I have so far. Im not looking for an answer I just need help getting in the ready right direction.
//define the lettersearch function
string letterSearch(string fullName) {
//create an array to hold the users entered variables
char userLetters[3];
//create a var to hold the letter positions
int found;
//Create a multi dimensional array to hold the letters removed and their posion the first
int letterPos[3][2];
//make full name all lowercase since C++ is a case senseative language
fullName = strLowerCase(fullName);
//tell the user to enter letters
cout << "\n Please enter three letters that are in your name.\n This search is case insensitive. " << endl;
//create a for loop to fill the array with answers
for (int i = 0; i < 3; i++){
//set the array with i
cin >> userLetters[i];
}
system("CLS");
//create a for loop to check for individual letters in the string fullname
for (int i = 0; i < 3; i++){
//set the search make make sure everything is lowercase
found = fullName.find(tolower(userLetters[i]));
//continue in this while loop untill there are not more instances of a given letter
while (found != string::npos){
//display what letter has been found and in what position
cout << "\n The letter " << userLetters[i] << " has been found at " << found << endl;
letterPos[i][0] = found;
char test = atoi(userLetters[i]);
letterPos[i][1] = test;
//continue the search from the last position
found=fullName.find(tolower(userLetters[i]),found+1);
}
}
return "test";
}