hey, kind of new to c++ started working with functions and am trying to write program using them
trying to make hangman game using functions, with my following code i am getting this error message
[linked error] undefined reference to 'askGuess()'
id returned 1 exit status
[build error] [ number5.exe] error 1
could please tell me what this error message means. i put my code so maybe can better identify why it is.
thanks for help in advance
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cctype>
using namespace std;
char askGuess();
int main()
{
//initial setup
const int MAX_WRONG = 8;// constant variable
vector<string> words;//creating words that will be in gmae for user to guess
words.push_back("HANGMAN");
words.push_back("DIFFICULT");
words.push_back("GUESS");
srand(static_cast<unsigned int>(time(0)));//help create random order
random_shuffle(words.begin(), words.end());// randamizies list
const string THE_WORD = words[0];// selects word from randomized list// moved all 4 under this to function
int wrong = 0;// starts number of guesses to 0
string soFar (THE_WORD.size(), '-');//how much word guessed so far
string used = "";//letters guessed already
cout << "Welcome to Hangman. Good Luck!!!" << endl;
while ((wrong < MAX_WRONG) && (soFar != THE_WORD))
{
cout << "\n\n You have " << (MAX_WRONG - wrong) << " incorrect guesses left\n";
cout << " You have used the following letters: \n" << used << endl;
cout << " So far, the word is " << soFar << endl;
askGuess();
if (wrong == MAX_WRONG)
{
cout << "it has taken you to many guess. YOU LOSE! ";
}
else
{
cout << " you got it. the words was " << THE_WORD << " YOU WIN!\n";
}
}
cin.get();
return 0;
}
char askGuess ( string usedLetterStr)
{
char guess;
cout << " enter your guess \n";
cout << guess;
guess = toupper(guess);//changes letter entered to uppercase b/c word is in upper case in vector
string used = "";
while (used.find(guess) != string::npos)
{
cout << "\nYou have already guess " << guess << endl;
cout << " Enter your guess: ";
cin >> guess;
guess = toupper(guess);// again just changes to uppercase
}
if ( THE_WORD.find(guess) != string::npos)
{
cout << "That's right " << guess << " is in the word." << endl;
for ( unsigned int i = 0; i < THE_WORD.length(); i++)
{
if (THE_WORD[i] == guess)
{
soFar[i] = guess;
}
}
}
else
{
cout << "sorry " << guess << " is not in the word\n";
++wrong;
}
}