Problem with code

Hey guys, The jumbled up word is completely wrong has letters in it that don't belong there :D im guessing im screwing up in the for loop where im jumbling up the words
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 int input = 0;
	std::string response;
    enum fields {WORD, HINT, NUM_FIELDS};
	const int MAX_WORDS = 5;
	srand(static_cast<unsigned int>(time(0)));
	std::string jumbleWords[MAX_WORDS][NUM_FIELDS] =
	{
		{ "wall", "do you feel you're banging your head against         something..."},
		{ "glasses", "these might help you see the answer..." },
		{ "labored", "going slowly, is it..." },
		{ "persistent", "keep at it..." },
		{ "jumble", "it's what the game is all about..." }
	};
	int choice = (rand() % MAX_WORDS);
	std::string theWord = jumbleWords[choice][WORD];
	std::string theHint = jumbleWords[choice][HINT];
	for (int x = 0; x < theWord.length(); x++)
	{
		int index1 = (rand() % theWord.length());
		int index2 = (rand() % theWord.length());
		char temp = theWord[index1];
		theWord[index1] = theWord[index2];
		theWord[index2] = temp;
	}
	std::cout << "\n\n                Welcome to Word Jumble ver1.00\n\n";
	std::cout << "Unscramble the letters to make a word\n";
	std::cout << "Press 1 to get a hint\n";
	std::cout << "Press 2 to quit..\n\n";
	std::cout << "The jumble is:  " << theWord << "\n\n";
	std::cout << "Your Guess:  ";
	std::cin >> response;
	while ((response != theWord) && (response != "2"))
	{
		if (response == "1")
		{
			std::cout << "\n" << theHint << "\n\n";
		}
		else
		{
			std::cout << "Sorry that's not it...\n\n";
		}
		std::cout << "\n\nEnter Guess:  ";
		std::cin >> response;
	}
	std::cout << "\n\nWell Done you guess right!!!!\n\n";
	system("PAUSE");
	return 0;
}
I have ran the program many times and the jumbled word if fine on my machine. I dont see any extra characters.
No idea for me it for example when the word is wall I have t's and e's inside the jumbled word
Topic archived. No new replies allowed.