title: Load functions using a case switch statement
body: <p>I'm writing a program in C++ and I've been able to get it to compile and start to run how ever when I choose an option the coresponding function that is supposed to be called by a switch-case statement isn't called. Am I missing something in my code?</p>
  
  <pre><code>//The following program framework is given.
  //Add the programming logic to complete the assignment.
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  //function prototypes should be placed here
  //Main must be the first function in the program. Write other functions after it.
  int main()
  {
  char cInput;
  string strFileName;
  vector&lt;string&gt; vecStudent;
  cout&lt;&lt;"Please enter the data file name (with location): ";
  cin &gt;&gt; strFileName;
  //call a function to read the content of the input file into
  //the vector vecStudent
  while (true)
  {
  cout&lt;&lt;"----------------------------------------"&lt;&lt;endl;
  cout&lt;&lt;" Student Record - Main Menu "&lt;&lt;endl;
  cout&lt;&lt;"----------------------------------------"&lt;&lt;endl;
  cout&lt;&lt;" Enter 1 to display ALL students"&lt;&lt;endl;
  cout&lt;&lt;" Enter 2 to add a student name"&lt;&lt;endl;
  cout&lt;&lt;" Enter 3 to delete a student name"&lt;&lt;endl;
  cout&lt;&lt;" Enter 4 to SAVE and quit the program"&lt;&lt;endl;
  cout&lt;&lt;"----------------------------------------"&lt;&lt;endl;
  cout&lt;&lt;"Enter menu option: ";
  cin&gt;&gt;cInput;
  switch (cInput)
  {
  case '1':
  //call function display names
     void displaynames();
  break;
  case '2':
     void addname();
  //call a function add name
  break;
  case '3':
      void deletename();
  //call function delete names
  break;
  case '4':
     void  saveandquit();
  //call function save and quit
  return 0;
  
  if( cInput != 1,2,3,4)
  cout&lt;&lt;"invalid input"&lt;&lt;endl;
  break;
  }
  }
  return 0;
  }
  
  int displaynames()
  {
      ifstream inFile;
      ofstream outFile;
      string strFileName;
      string strFName,strLName;
      vector&lt;string&gt; vecStudent;
      char line[80];
  
      // open input file
      inFile.open(strFileName.c_str());
      if (inFile.fail())
      {
          cout &lt;&lt; " Input file error!" &lt;&lt; endl;
              return -1;
      }
      while (inFile&gt;&gt;strFName&gt;&gt;strLName)
          vecStudent.push_back(strFName+ " "+strLName);
      inFile.close();
  
      //display the content of the vector
      for(int i =0; i&lt; vecStudent.size();i++)
          cout&lt;&lt;vecStudent[i]&lt;&lt;endl;
  return 0;
  }
  
  int addname()
  {
      ifstream inFile;
      ofstream outFile;
      string strFileName;
      string strFName,strLName;
      vector&lt;string&gt; vecStudent;
      char line[80];
      //add a new name
      cout &lt;&lt; endl&lt;&lt; " Enter a new name( First and Last Name):";
      cin&gt;&gt;strFName&gt;&gt;strLName;
      vecStudent.push_back(strFName+ " "+strLName);
  
      // open output file for writing
      outFile.open(strFileName.c_str());
      if ( outFile.fail())
      {
          cout&lt;&lt;" Output file error! Student was not added"&lt;&lt;endl;
          return -1;
      }
  
      //display the content of the vector
      for(int i=0; i&lt;vecStudent.size(); i++)
          cout&lt;&lt; vecStudent[i]&lt;&lt;endl;
  
      for(int i=0; i&lt;vecStudent.size();i++)
          outFile&lt;&lt;vecStudent[i]&lt;&lt;endl;
      outFile.close();
  return 0;
  }
  
  
  int saveandquit()
  {
      ifstream inFile;
      ofstream outFile;
      string strFileName;
      string strFName,strLName;
      vector&lt;string&gt; vecStudent;
      int i=0;
      char line[80];
      //     open output file for writing
      outFile.open(strFileName.c_str());
      if ( outFile.fail())
      {
          cout&lt;&lt;" Output file error!"&lt;&lt;endl;
          return -1;
      }
  
      //display the content of the vector
      for(int i=0; i&lt;vecStudent.size(); i++)
          cout&lt;&lt; vecStudent[i]&lt;&lt;endl;
  
      for(int i=0; i&lt;vecStudent.size();i++)
          outFile&lt;&lt;vecStudent[i]&lt;&lt;endl;
      outFile.close();
      cout &lt;&lt; " file saved. enter -1 to quit";
      cin&gt;&gt; i;
      if( i=-1)
  
  
      return 0;
  }
  
  
  
   int deletename()
  {
      ifstream inFile;
      ofstream outFile;
      string strFileName;
      string strFName,strLName;
      vector&lt;string&gt; vecStudent;
      int namepos = 0;
      char line[80];
  
      inFile.open(strFileName.c_str());
      if (inFile.fail())
          cout &lt;&lt;"Input file error!"&lt;&lt;endl;
  
      //read the names from the file into the vector
      while (inFile &gt;&gt; strFName &gt;&gt; strLName)
          vecStudent.push_back(strFName+" "+strLName);
      inFile.close();
  
      cout &lt;&lt;"\nEnter the name to be deleted (First name and Last name): ";
      cin &gt;&gt;strFName &gt;&gt;strLName;
  
      int i=0, pos=-1;
      int size = vecStudent.size();
      bool found=false;
      // use a linear search to find the name in the vecotor of names
  
      while (i &lt; size &amp;&amp; !found)
      {
          if (vecStudent [i] == strFName+" "+strLName)
          {
              found = true;
  
      cout &lt;&lt;"\nthat name is in the "&lt;&lt;(pos + 1) &lt;&lt;" position in the list\n";
      cout &lt;&lt;"Please enter the position in list\n";
      cin&gt;&gt; pos;
      // use an iterator to delete name from vecStudent. vector.erase requires an iterator. used a while loop to find the name and make sure it was in the
      // vector of strings. then the loop displays the position in the vector that the string is. the program asks the user to enter the number position of the name
      // from there the user enters the name and the program uses a for loop to find the position and the built in vector.erase to remove the name from the list.
      for(int i=0; i ==pos; i++)
      {
          if(i == pos)
          {
              vecStudent.erase (vecStudent.begin());
          }
      }
      }
      }
  
      return 0;
  }
  </code></pre>