#include <iostream>
#include <ctime>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;
//Types and Arrays
string word[16] = {"GOLDFISH", "COMPUTER", "ANONYMOUS", "JACKET", "SHARP", "SERVICE", "EFFORT", "CHARACTER", "CHANGE", "WITHOUT", "PRODUCT", "UNFOLDS", "MUSIC", "MOMENT", "LIFETIME", "PROVIDE"};
char guess[50];
static const char Y= 'Y';
static const char N= 'N';
char ans;
// Functions
int instructions();
int game();
int main()
{
cout << "\tWelcome to Word Jumble By Khoanyneosr!\n";
cout << "\nWould you like to see the instructions?"
<< "\n\t1) Yes = Y"
<< "\n\t2) No = N\n- ";
bool rep=1;
while (rep) {
cin >> ans;
switch (toupper(ans)) {
case Y:
instructions();
rep=0;
break;
case N:
game();
rep=0;
break;
default:
cout << "\n\nInvalid input.\n\n- ";
cin.clear();
rep=1;
break;
}
}
return 0;
}
int instructions()
{
system("cls");
cout << endl << endl << "\tINSTRUCTIONS" << endl;
cout << endl << "1 - You will be presented with a word. Your job is to guess it." << endl;
cout << endl << "2 - At the beginning of the game your given 10 points." << endl;
cout << endl << "3 - You will be given 1 hint. Everytime you have to revisit\nthe hint 1 point will be deducted." << endl;
cout << endl << "4 - For everytime you guess wrong 1 point will be deducted." << endl;
cout << endl << "5 - When your point value reaches 0, the game is over." << endl;
cout << endl << "You can exit at anytime by pressing Q." << endl;
cout << endl << endl << "\tGood Luck!" << endl << endl << endl;
system("pause");
return game();
}
int game()
{
cout << endl << "what is your guess?";
cin.getline(guess, 50);
cout << endl << guess[50] << endl;
return 0;
}
I don't know whats wrong with my code, but i do know that after i answer the first question in the program for some reason the input carry's down to my other input sections... if that makes sense. If you wouldn't mind, please look it over, compile it and PLEASE PLEASE PLEASE tell me whats wrong.