title: How to signal EOF on MAC OS X with CLion
body: <p>I have recently started to learn C++ and have been following the book Accelerated C++. I am on Chapter 3 and I tried to run the program given in the book. I am working on CLion on my MAC OS. The code is the following : </p>
  
  <pre><code>#include "iomanip"
  #include "ios"
  #include "iostream"
  #include "string"
  #include "vector"
  #include "algorithm"
  
  using std::cin; using std::cout;
  using std::endl; using std::string;
  using std::setprecision; using std::streamsize;
  using std::vector; using std::sort;
  
  int main()
  {
      // Ask for and read student's name
      cout &lt;&lt; "Please enter your name: ";
      string name;
      cin &gt;&gt; name;
      cout &lt;&lt; "Hello, "&lt;&lt; name &lt;&lt; "!"&lt;&lt; endl;
  
      // Ask for and read mid-term and final grades
      cout &lt;&lt; "Please enter your mid-term and final grades: ";
      double midterm_grade, final_grade;
      cin &gt;&gt;midterm_grade &gt;&gt; final_grade;
  
      // Ask for homework grades
      cout &lt;&lt; "Enter all your homework grades, followed by end-of-file";
  
      vector&lt;double&gt; homework;
      double x;
      //Invariant : Homework contains all homework grades read so far
  
      while (cin &gt;&gt; x)
      {
          homework.push_back(x);
      }
  
      // Check that the student entered some homework grade
  
      typedef vector&lt;double&gt;:: size_type vector_size;
      vector_size size = homework.size();
  
      if(size == 0)
      {
          cout &lt;&lt; "You must enter your grades. Please try again" &lt;&lt; endl;
          return 1;
      }
  // Sort the grades
      sort(homework.begin(), homework.end());
  
  // Compute the median output grade
  
      vector_size mid = size/2;
      double median;
      median = size % 2 == 0 ? (homework[mid] + homework[mid-1])/2 : homework[mid];
  
  // Compute and write the final grade
  
      streamsize prec = cout.precision();
      cout &lt;&lt; "Your final grade is :" &lt;&lt; setprecision(3) &lt;&lt; 0.2*midterm_grade + 0.4*final_grade + 0.4*median&lt;&lt; setprecision(prec) &lt;&lt; endl;
      return 0;
      }//
  </code></pre>
  
  <p>The program compiles well and I can enter the name and also the grades. But then when I press Ctrl+D (which is the EOF confirmed from the terminal, also suggested here <a href="https://stackoverflow.com/questions/15848134/how-to-signal-eof-of-stdin-when-in-mac-osx-terminal">How to signal EOF of stdin when in mac osx terminal?</a>) or Cmd+D (as suggested also). </p>
  
  <p>When I press Ctrl+D, the program just restarts. On pressing Cmd+D, it has some unusual behaviour. It may work sometimes, and other times it doesnt. I have also tried to look in the Preferences-> Keymap but I can't find which parameter to set. </p>
  
  <p>I think I am missing some really basic key settings here. 
  Thank you for your help. </p>