title: Making program use less CPU when waiting in an infinite loop
body: <p><strong>Setup</strong>: I have this program in c++:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  using namespace std;
  int main(){
      HWND window;
      AllocConsole();
      window = FindWindowA("ConsoleWindowClass", NULL);
      ShowWindow(window,0);
  while (1){  
  if (GetKeyState('A'))
          {
      system("start love.mp3");
      return 0;
          }
      }
  return 0;
  }
  </code></pre>
  
  <p>So the program runs as a process and waits until the key A is pressed. And then it plays the love.mp3 file :) </p>
  
  <p>However, when the program is waiting it uses up 25% of the CPU usage.</p>
  
  <p><strong>Qustion</strong>: Is there a way to reduce this so that the program doesn't consume so much of the CPU? </p>