I can't figure out why this code isn't working that I have put together when ever I put in the answer it just stops write there and the while loop it's working properly either any help would be appreciated.
// Word Jumble
// 11/02/2012
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
{"fall","have a nice trip see you next???"},
{"fart","something that stinks"},
{"dart","something you throw at a bar."},
{"art","leonardo,mikey,donatello,ralph"},
{"batman","joker"}
};
srand(static_cast<unsigned int> (time(0)));
int choice = (rand()% num_words);
string theword = words[choice][word];//word to guess
string thehint= words[choice][hint];//hint for the word
string jumble = theword; //jumbled version of the word
int length = jumble.size();
for (int i=0; i < length; i++)
{
int index1= (rand() % length);
int index2= (rand() % length);
char temp = jumble[index1];
jumble[index1]= jumble[index2];
jumble[index2]= temp;
}
cout << "Welcome to the Word Jumble Playing game"<< endl;
cout << "Can you unscramble the words?" << endl;
cout << "If you need help to figure the word out enter in 'hint'!" <<endl;
cout << "If you can't figure it enter in 'quit'" << endl;
cout << "The jumbled word is going to be!!!!" << jumble << endl;
string guess;
cout << "What is your guess going to be!!!" << endl;
cin >> guess;
int yes;
while (guess !="quit");{
if (guess == "hint")
{
cout << thehint;
}
if (guess==theword)
{
cout << "YOU GOT IT!!! would you like to try another word???" << endl;
string yes;
if (guess== yes)
{
cin >> guess;
cout << "the new word is:" << jumble << endl;
}
}
}
return 0;
system("pause");
}
// Word Jumble
// 11/02/2012
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
enum fields {word, hint, num_fields};
constint num_words =5;
const string words[num_words][num_fields]=
{
{"fall","have a nice trip see you next???"},
{"fart","something that stinks"},
{"dart","something you throw at a bar."},
{"art","leonardo,mikey,donatello,ralph"},
{"batman","joker"}
};
srand(static_cast<unsignedint> (time(0)));
int choice = (rand()% num_words);
string theword = words[choice][word];//word to guess
string thehint= words[choice][hint];//hint for the word
string jumble = theword; //jumbled version of the word
int length = jumble.size();
for (int i=0; i < length; i++)
{
int index1= (rand() % length);
int index2= (rand() % length);
char temp = jumble[index1];
jumble[index1]= jumble[index2];
jumble[index2]= temp;
}
cout << "Welcome to the Word Jumble Playing game"<< endl;
cout << "Can you unscramble the words?" << endl;
cout << "If you need help to figure the word out enter in 'hint'!" <<endl;
cout << "If you can't figure it enter in 'quit'" << endl;
cout << "The jumbled word is going to be!!!!" << jumble << endl;
string guess;
cout << "What is your guess going to be!!!" << endl;
cin >> guess;
int yes;
while (guess !="quit");{
if (guess == "hint")
{
cout << thehint;
}
if (guess==theword)
{
cout << "YOU GOT IT!!! would you like to try another word???" << endl;
string yes;
if (guess== yes)
{
cin >> guess;
cout << "the new word is:" << jumble << endl;
}
}
}
return 0;
system("pause");
}
Get rid of the semicolon on line 53. It's making the while loop run indefinitely.