I currently trying to make a word jumbler with a betting game within. I typed in the word jumbler part and then added the play loop and finally the betting part. I used visual studios to create the program. I build the code and it had no errors but one warnings saying that : bet cannot be initialized. The problem
I am having is that it builds fine then when I run the program it crashes instantly why?
int main()
{
enum fields {WORD, HINT, NUM_FIELDS};
const int NUM_WORDS = 8;
const int MAX_GUESSES = 5;
const string WORDS[NUM_WORDS][NUM_FIELDS] =
{
{"supercalifragilisticexpialdocious", "Famous song title from the Walt Disney movie Mary Poppins."},
{"mightier", "The pen is than the sword."},
{"defiance", "A daring or bold resistance to authority or to any opposing force."},
{"equivalently", "Equal in value, measure, force, effect, and significance."},
{"jumble", "It's what the game is all about."},
{"terminator", "This person used to assassinate but now protects John Connor."},
{"prenatal", "To give birth."},
{"deprecatingly", "To express earnest disapproval of."}
};
string guess;
int money = 50;
int bet;
char another;
do
{
srand(time(0));
int choice = (rand() % NUM_WORDS);
string theWord = WORDS[choice][WORD]; // word to guess
string theHint = WORDS[choice][HINT]; // hint for word
string jumble = theWord; // jumbled version of 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 << "\t\t\tWelcome to Word Jumbler!\n\n";
cout << "Unscramble the letters to make a word.\n";
cout << "Type 'hint' for a hint.\n";
cout << "Type 'quit' to quit the game.\n\n";
cout << "You only get five tries to guess the word.\n";
cout << "The jumbled word is: " << jumble;
cout << "You currently have $" << money << " on hand.";
cout << "\nPlace your bet and guess the word.";
while(bet < 1 || bet > money);
{
if (bet < 1)
cout << "\nNeed more money cheapstake!";
if (bet > money)
cout << "\nYou don't have enough weakling!";
cout << "\n\nPlace your bet again! : ";
cin >> bet;