// Hangman Redo Program
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

//Functions
void instructions();
void game();

// Types and Arrays
string choice;
string inst;
const int MAX_WRONG = 8;
vector<string> words;
const string THE_WORD = words[0];
string soFar (THE_WORD.size(), '-');
int wrong = 0;
string used = "";

int main()
{
  // begin of welcome
	for (int f = 0; f < 11; f++) // formating
		{
			cout << endl;
		}

	cout << "\t\tWelcome to Hangman 2.0 By Khoanyneosr!";

		for (int i = 0; i < 14; i++) // for statement to create space under title
		{
			cout << endl;
		}
			system("pause"); // creates a pause;

			system("cls"); // clears the console screen
		cout << endl << "Would you like to see the instructions?\n\n";
		cout << endl << "Yes - Y" << endl;
		cout << endl << "No - N\n\n- ";
			cin >> choice;
		
		transform(choice.begin(), choice.end(), choice.begin(), toupper); // toupper algorithm
		cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
	
bool done = false;
	while (done == false)
	{
		

		if (choice == "Y")
		{
			instructions();
			done = true;
			break;
		}
		else if (choice == "N")
		{
			game();
			done = true;
			break;
		}
		else
		{
			cout << endl << "Invalid input.\n- ";
			cin.clear();
			cin >> choice;

		transform(choice.begin(), choice.end(), choice.begin(), toupper); // toupper algorithm
		cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); // limit cin to one character.

		}
	};
	// end of welcome

	return 0;
}
void instructions()
{
	system("cls");
	cout << endl << "\t\tINSTRUCTIONS: ";
	cout << endl << "1 - You'll be presented with some blank spaces.\n";
	cout << endl << "2 - Your job is to guess which letters go in the spaces.\n";
	cout << endl << "3 - If you guess the right letter, then you'll be given 1 point.\n";
	cout << endl << "4 - If you guess the wrong letter 1 point will be deducted.\n";
	cout << endl << "5 - If you think that you know the word, you can guess the word\n\n\tby typing \"Guess\" at any time.\n\n";
	cout << endl << "Good Luck!" << endl << endl;
	system("pause");
	game();
}
void game()
{
	words.push_back("ALPHABET");
	words.push_back("SKUNK");
	words.push_back("ANIMALS");
	words.push_back("TABLE");
	words.push_back("CASE");
	words.push_back("MONITOR");
	words.push_back("TELEVISION");
	words.push_back("SOAP");
	words.push_back("BERUIT");
	words.push_back("WRAP");
	words.push_back("CHAIR");
	words.push_back("CHARTER");
	words.push_back("COMPUTER");
	words.push_back("SHARPENER");
	words.push_back("PENCIL");
	words.push_back("WALLS");
	words.push_back("LUNG");
	words.push_back("NOTHING");
	words.push_back("HAIR");
	words.push_back("SECRUITY");
	words.push_back("NIXON");
	words.push_back("DESTROY");
	words.push_back("OUTLET");
	words.push_back("GLOBE");

			srand(static_cast<unsigned int>(time(0)));
	random_shuffle(words.begin(), words.end());
	string soFar (THE_WORD.size(), '-');
	string used = "";
	system("cls");

		while ((wrong < MAX_WRONG) && (soFar != THE_WORD))
		{
			cout << "\n\nYou have " << (MAX_WRONG - wrong);
			cout << " incorrect guesses left.\n";
			cout << "\nSo far, the word is:\n" << soFar << endl;

			char guess;
			cout << "\n\nEnter a guess: ";
			cin >> guess;
			cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); // limit cin to one character.
			guess = toupper(guess);
			while (used.find(guess) != string::npos)
			{
				cout << "\nYou've already guessed " << guess << endl;
				cout << "Enter your guess: ";
				cin >> guess;
				guess = toupper(guess);
			}

			used += guess;

			if (THE_WORD.find(guess) != string::npos)
			{
				cout << "That's right! " << guess << " is in the word.\n";
			
				// update the newly guessed letter into the word
				for (unsigned int i = 0; i < THE_WORD.length(); ++i)
				{
					if (THE_WORD[i] == guess)
					{
						soFar[i] = guess;
					}
				}
			}
			else
			{
				cout << "Sorry, " << guess << " isn't in the word.\n";
				++wrong;
			}
		}

		// shut down
		if (wrong == MAX_WRONG)
		{
			cout << "\nYou've been hanged!";
		}
		else
		{
			cout << "\nThe word was " << THE_WORD << endl;
		}

}

Sorry for the lengthy code i just thought i should add it all. I've been having problems with function calling with this program and have not been able to fix it. So i cleared the function arguments and made the game() function void. Then it compiled, but when it compiled it said DEBUG ASSERTION FAILED... Then a bunch of stuff about the file location and line 932 then VECTOR SUBSCRIPT OUT OF RANGE...

Feel free to compile the code if you want...

Thanks

I get quite a few compilation errors with your code about your use of the methods in algorithm. As an aside, check out http://www.daniweb.com/software-development/cpp/threads/262894 for Narue's solution to the problem with using toupper in this context.

Edit: you didn't include <limits> for the cin.ignore call

vector<string> words;
const string THE_WORD = words[0];

What is words[0] equal to when you are trying to assign it? There is nothing in words, it's only been declared. Even if it were valid, there's really no need to have these variables global anyway, I'm not sure why you did that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.