title: Using A Delete Keyword With Arrays C++
body: <p>So with another addition to my program, I have decided to include a function where you can remove all information from <code>myCourses[10]</code>. The newest code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  struct Course
  {
      string name;
      double grade;
      int block;
  };
  
  Course enter_course()
  {
      Course foo;
  
      cout &lt;&lt; "What is the name of the course you wish to enter? (Use this format: ExampleFormat)\n";
      cin &gt;&gt; foo.name;
      cout &lt;&lt; "What block is " &lt;&lt; foo.name &lt;&lt; " ?\n";
      cin &gt;&gt; foo.block;
      cout &lt;&lt; "What is your current grade as a percent?\n";
      cin &gt;&gt; foo.grade;
  
      return foo;
  }
  
  void display_courses(Course courseList[10], int courseCount)
  {
      for (int i=0; i&lt;courseCount; i++){
          cout &lt;&lt; i+1 &lt;&lt; "\t" &lt;&lt; courseList[i].name 
               &lt;&lt; "\t\tBlock: " &lt;&lt; courseList[i].block
               &lt;&lt; "\tGrade: " &lt;&lt; courseList[i].grade &lt;&lt; "%" &lt;&lt; endl;
      }
  }
  
  double get_gpa(Course courseList[10], int courseCount)
  {
      double gradePoints;
      double total = 0.0;
      for (int i=0; i&lt;courseCount; i++){
          if (courseList[i].grade &lt; 100){
              gradePoints = 4;
          } 
          if (courseList[i].grade &lt; 90){
              gradePoints = 3;
          }
          if (courseList[i].grade &lt; 80){
              gradePoints = 2;
          }
          if (courseList[i].grade &lt; 70){
              gradePoints = 1;
          }
          if (courseList[i].grade &lt; 60){
              gradePoints = 0;
          }
          total += gradePoints;
      }
  
      return total*1.0/courseCount;
  
  }
  
  void display_options()
  {
      cout &lt;&lt; "1. Exit\n";
      cout &lt;&lt; "2. Enter a Course\n"; 
      cout &lt;&lt; "3. Display Courses\n";
      cout &lt;&lt; "4. Display GPA\n";
      cout &lt;&lt; "5. Request a text file output\n";
      cout &lt;&lt; "6. Delete Grades\n";
  
      cout &lt;&lt; "\n\n";
  }
  
  int main()
  {
      bool exit=0;
      int option;
      int courseCount=0;
      Course myCourses[10]; //nobody should ever take more than 10 courses! 
  
      while (exit == 0)
      {
          cout &lt;&lt; "GradeBook 2.0\n";
          display_options();
          cout &lt;&lt; "Enter a command.\n";
          cin &gt;&gt; option;
  
          switch (option)
          {
              case 1: 
                  exit = 1;
                  break;
              case 2:
                  myCourses[courseCount] = enter_course();
                  courseCount++;
                  break;
              case 3:
                  display_courses(myCourses, courseCount);
                  break;
              case 4:
                  cout &lt;&lt; get_gpa(myCourses, courseCount) &lt;&lt; endl;
                  break;
              case 5:
                  ofstream outputFile;
                  outputFile.open("userGrades.txt");
                  for (int i = 0; i &lt; courseCount; i++)
                  {
                      outputFile &lt;&lt; myCourses[i].name &lt;&lt; " " &lt;&lt; myCourses[i].grade &lt;&lt; " " &lt;&lt; myCourses[i].block &lt;&lt; endl;
                  }
                  outputFile.close();
                  cout &lt;&lt; "Grades saved to file!" &lt;&lt; endl;
                  break;
              case 6:
                  cout &lt;&lt; "Removing data...\n";
                  delete[] myCourses;
                  break;
          }
      }
  
      return 0;
  }
  </code></pre>
  
  <p>However, I receive the following errors:
  error C2360: initialization of 'outputFile' is skipped by 'case' label (Line 114)
  IntelliSense: transfer of control bypasses initialization of: variable "outputFile" (declared at line 105) (Line 89)
  warning C4154: deletion of an array expression; conversion to pointer supplied (Line 116)
  Does anyone know what is wrong with having a <code>delete[]</code> keyword inside a switch block?</p>