title: How to terminate a program with Ctrl-D?
body: <p>I am trying to write a simple program that simulates a calculator. I would like the program to exit or turn-off when the <kbd>Ctrl</kbd>+<kbd>D</kbd> keystroke is made. I searched through stackoverflow and saw other examples of <kbd>Ctrl</kbd>+<kbd>C</kbd> or <kbd>Ctrl</kbd>+<kbd>A</kbd> but the examples are in java and C.</p>
  
  <p>for C:</p>
  
  <pre><code>(scanf("%lf", &amp;var);
  </code></pre>
  
  <p>for java, a <code>SIGINT</code> is raised when <kbd>Ctrl</kbd>+<kbd>Z</kbd> is pressed.  </p>
  
  <pre><code>signal(SIGINT,leave);  
      for(;;) getchar();
  </code></pre>
  
  <p>I am wondering what can I do for <kbd>Ctrl</kbd>+<kbd>D</kbd> in C++...</p>
  
  <p>Thanks everyone!</p>