title: Function Call in switch statement.
body: <p>Hey guys I'm trying to work out how to call a function in my code using a switch statement. I have tried to look for many different references but no matter what nothing seems to work if somebody could please put me on the right path that would be a big help. Here's the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int playGame(string word); 
  
  int main() 
  {
  int choice;
  bool menu = true;
  do{
  cout &lt;&lt;"Please select one of the following options:  \n";
  
  cout &lt;&lt; "1: Play\n"
      "2: Help\n"
      "3: Config\n"
      "4: Quit\n";
  
  cout &lt;&lt; "Enter your selection (1, 2 and 3): ";
  cin &gt;&gt; choice;
  //*****************************************************************************
  // Switch menu to display the menu.
  //*****************************************************************************
      switch (choice)
   {
        case 1:
          cout &lt;&lt; "You have chosen play\n";
          int playGame(string word); 
          break;
       case 2:
          cout &lt;&lt; "You have chosen help\n";
          cout &lt;&lt; "Here is a description of the game Hangman and how it is    played:\nThe      word to guess is represented by a row of dashes, giving the number of letters, numbers and category. If the guessing player suggests a letter or number which occurs in the word, the other player writes it in all its correct positions";
          break; 
           case 3:
          cout &lt;&lt; "You have chosen Quit, Goodbye.";
          break;
      default:
          cout&lt;&lt; "Your selection must be between 1 and 3!\n";
  
      }
  
  }while(choice!=3);    
  getchar();
  getchar();
  
  
  cout &lt;&lt; "You missed " &lt;&lt; playGame("programming");
  cout &lt;&lt; " times to guess the word programming." &lt;&lt; endl;
  }
  
  
  
  
  
  
  int playGame(string word) //returns # of misses
  
  {
      //keep track of misses
      //guess is incorrect
      //repeated guess of same character
      //guess is correct 
  
      int misses = 0;
      int exposed = 0; 
      string display = word;
      for(int i=0; i&lt; display.length(); i++)
          display[i] ='*';
  
  
      while(exposed &lt; word.length()) {
          cout &lt;&lt; "Miss:" &lt;&lt; misses &lt;&lt; ":";
          cout &lt;&lt; "Enter a letter in word ";
          cout &lt;&lt; display &lt;&lt; " : ";
          char response;
          cin &gt;&gt; response; 
  
          bool goodGuess = false; 
          bool duplicate = false;
          for(int i=0 ; i&lt;word.length() ; i++) 
              if (response == word[i]) 
              if (display[i] == word[i]) {
                  cout &lt;&lt; response &lt;&lt; " is already in the word.\n";
                  duplicate = true; 
                  break;
              } else {
                  display[i] = word[i];
                  exposed++; 
                  goodGuess = true; 
              }
              if (duplicate)
                  continue;
  
              if (!goodGuess){
                  misses ++;
              cout &lt;&lt; response &lt;&lt; " is not in the word.\n";
  
              }
      }
      cout &lt;&lt; "Yes, word was " &lt;&lt; word &lt;&lt; "." &lt;&lt; endl;
      return misses;
  }
  </code></pre>