title: How do you break out of a loop by a terminating character?
body: <p>I am trying to write a simple demonstration program that will break out of a loop upon entering a designated character. I was able to do this successfully until I wanted to add the extra condition that I did not exceed my array. This code will not break out of the loop when I enter the designated character and I cannot figure out why. The logic and setup of the code seems sound!        </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  char input[10];
  char breakout = '!';
  int idx;
  
  int main(void)
  {
  printf("Input characters until %c character is used to break out", breakout);
  
  for(idx = 0; input[idx] != breakout &amp;&amp; idx &lt; 10; idx++)
  {
      scanf("%c", &amp;input[idx]);
  }
  
  printf("Program terminated:");
  
  getchar();
  return 0;   
  }
  </code></pre>
  
  <p>It seems as though the condition of the for loop SHOULD evaluate false upon entering the '!' character, but it is not. Thanks guys</p>