Unsure how to go about this Str manipulation

What I am trying to do here is take a full name, eg. Mike W. Heintzman and allow the user to search for three letters within the name. Then I want to be able to take out the three letters but save their position (and letter value) so that I can put them back into the name shortly after. Where I am stuck at right now is taking the user entered characters, which I have combined into an array, and find all instances of that letters and their letter POS. I know how I could do this if I was just searching for one letter but I cant wrap my head around an algorithm to do this, just looking for a pointer in the right direction not my work to be done for me but any help is appreciated.
If you are using std::string then use its family of methods find. If you are dealing with a character array then use C standard functions as for example strchr.
Last edited on
Thanks alot for getting me in the right direction there. Now i just have one issue the code below works perfect except for one thing. the string i am finding these letters in it: " Mike W. Heintzman" and the letters I am searching are m,i, and e. It finds all instances of the i and the e but only the last instance of the m not the one in Mike, any idea why?

	int	found;

	for (int i = 0; i < 3; i++){
	  found = fullName.find(userLetters[i]);

		while (found != string::npos){

			 cout << "\n The letter " << userLetters[i] << " has been found at " << found << endl;

C++ is case sensitive. M and m are considered to be two different things
Topic archived. No new replies allowed.