String function problem

Can anyone tell me why this function will not return the string with all of the duplicates erased from the string?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  void delete_repeats(string & theString)
	{

		int left = 0;
		

		while (left < (theString.length() - 1))
		{
			int right = left + 1;
			
			while (right < theString.length())
			{
				if (theString[right] != theString[left])
				{

					right++;
				}//end if
				else
				{
					for (int i = (right <= (theString.length() - 2));;)
					{
						theString.at(i) = theString.at(i + 1);

					}//end for

				}theString.erase(theString.length() - 1);
					left++;
			}//end second while
		
		} //end of first while
		
	} // end delete_repeats function
I think the reason is in my for loop and I cannot figure it out for the life of me.
Topic archived. No new replies allowed.