title: Not using system("PAUSE") terminates my program
body: <p>I have make a program that take a number and a separator. If the user press enter, then the program will print the total of the number.</p>
  <p>example input: 2[space]3[enter] will print &quot;total = 5&quot;, 1[space]2[space]3[enter] will print &quot;total = 6&quot;, but if I input 2a3[enter], the program will get terminated and exit instead of printing &quot;error!&quot; and the &quot;press ENTER...&quot; message. Previously, I use the system(&quot;PAUSE&quot;) function and there was no problem(the error message appear). And then I know that it is not standard, so I replace it with 2 lines of code(you can see it in the code) and the problem occur.</p>
  <p>My input:</p>
  <p>2[space]3[enter] --&gt; print &quot;total = 5&quot;</p>
  <p>2a3[enter] --&gt; the program gets terminated instead of printing &quot;error!&quot; and the &quot;press ENTER...&quot; message</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      int num, total;
      char separator;
  
      for(;;)
      {
          scanf(&quot;%d%c&quot;, &amp;num, &amp;separator);
          total += num;
  
          if(separator == '\n')
          {
              printf(&quot;total = %d\n&quot;, total);
              break;
          }
          else if(separator == ' ')
          {
              //do nothing
          }
          else
          {
              printf(&quot;error!\n&quot;);
              break;
          }
      }
  
      printf(&quot;press ENTER to exit...&quot;); //this
      getchar(); //two lines
      //previously, I use system(&quot;PAUSE&quot;), and there is no problem.
  
      return 0;
  }
  </code></pre>
  <p>I use gcc 10.3.0 and Windows 10 OS.</p>
  <p>Can anyone explain to me why this problem occur?</p>