title: Program freezing up, not accepting inputs? Correct clock?
body: <pre><code>    #include&lt;iostream&gt;
      #include&lt;conio.h&gt;
      #include &lt;chrono&gt;
      #include &lt;ctime&gt;
  
      using namespace std;
      typedef std::chrono::high_resolution_clock Clock;
      /*struct*/ class Car
      {
      private:
  
      int carYear;
      string carMake;
      string carModel;
      int carSpeed;
      float carGallons;
      public:
  
      Car(int cY = 0, string cMa = "", string cMo = "", int cS = 0, float cG = 10)
      {
          carYear = cY;
          carMake = cMa;
          carModel = cMo;
          carSpeed = cS;
          carGallons = cG;
      }
      Car()
      {
          carMake = "Bugatti";
          carYear = 2020;
          carModel = "Chiron";
      }
      int getCarYear() { return carYear; }
      string getCarMake() { return carMake; }
      string getCarModel() { return carModel; }
      int getCarSpeed() { return carSpeed; }
      float getCarGallons() { return carGallons; }
      void setCarSpeed(int cS) { carSpeed = cS; }
      void setCarGallons(float cG) { carGallons = cG; }
      void accelerate()
      {
          startCar();
          if(carGallons&gt;0)
          { 
          carSpeed += 5;
          carGallons -= .5;
          }
          else if (carGallons &lt; 0)
          {
              carGallons = 0;
              cout &lt;&lt; "Please refill tank!";
          }
      }
      void brake()
      {
          startCar();
          if(carSpeed&gt;0&amp;&amp;carGallons&gt;0)
          { 
          carSpeed -= 5;
          carGallons -= .2;
          }
          else if(carSpeed&lt;0&amp;&amp;carGallons&lt;0)
          {
              carSpeed = 0;
  
              cout &lt;&lt; "Your car isn't moving!";
          }
      }
      void fillUP()
      {
  
          if (carSpeed &gt; 0)
          {
              cout &lt;&lt; "The car is still moving!";
          }
          else if(carSpeed==0)
          {
          if (carGallons &gt; 22)
          {
              cout &lt;&lt; "Car is full!";
              carGallons = 22;
          }
          else
          {
  
          carGallons += .2;
          }
          }
      }
      void startCar(bool carOn=true)
      {
  
          while (true)
          {
              std::chrono::system_clock::time_point then;
              auto now = std::chrono::system_clock::now();
              auto duration = now - then;
              then = now;
              if (false) return;
              {
              auto s = std::chrono::duration_cast&lt;std::chrono::duration&lt;double&gt;&gt;(duration);
              carGallons -= s.count() * .05f;
          }
          }
      }
      };
  
      int main()
      {
  
       bool carOn = false;
      Car userCar(2020, "Bugatti", "Chiron");
      cout &lt;&lt; "\nStart your new " &lt;&lt; userCar.getCarYear()&lt;&lt;" "&lt;&lt; userCar.getCarMake() &lt;&lt;" "&lt;&lt; userCar.getCarModel()&lt;&lt;"!";
      cout &lt;&lt; "\nHit O to start your Engine!";
      char ch;
      cin &gt;&gt; ch;
      if (ch== 'o'|| ch=='O') {
          bool carOn = true;
          cout &lt;&lt; "\nCar is now on! Safe driving!\n";
      int c = 0;
      while (1)
      {
          c = 0;
          switch (c = _getch())
          {
  
          case 32:
              userCar.fillUP();
              break;
          case 72:
              cout &lt;&lt; userCar.getCarSpeed() &lt;&lt; " " &lt;&lt; userCar.getCarGallons();
              userCar.accelerate();
              break;
  
          case 80:
              userCar.brake();
              break;
  
          case 75:cout &lt;&lt; "\nleft"; break;
          case 77:cout &lt;&lt; "\nright"; break;
          default:
              cout &lt;&lt; " ";
          }
      }
  
      }
      else
      {
          cout &lt;&lt; "\nCar is not on!";
      }
          return 0;
      }
  </code></pre>
  
  <p>I'm running into an issue where after taking input from the user to turn on their car the inputs freeze up and the switch doesn't accept any other inputs. I know it has something to do with how I'm calling my functions inside the switch but I'm at a loss for how to correct it. Also, I'm fairly certain I've incorrectly implemented my clock inside startCar, it's supposed to subtract gas while the car is on.</p>