title: Why is half of my char array white space?
body: <p>I am trying to fill a char array, but for some reason each time I hit enter it inputs Line Feed into the array, which means half of my array is LF. I tried doing fflush, but that doesn't seem to work.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void bubbleSortChar( char arr[], int size);
  //The instruction say to get ch *then* call binarySearchCh, so I think you
  //have to add a field.
  void binarySearchCh(char arr[], int size,char val,int findall); 
  
  main()
  {
      char chArray[100];
      char ch;
      int i = -1;
  
  
      while(++i&lt;100 &amp;&amp; scanf("%c",&amp;chArray[i]))
          fflush(stdin);
  
      bubbleSortChar(chArray,100);
  
      fflush(stdin);
      printf("Enter a char to find.");
      scanf("%c",&amp;ch);
  
      binarySearchCh(chArray,100,ch,1);
  
  
  }    
  </code></pre>
  
  <p>Is there a way to do this without manually removing the whitespace each time? I could do that but it seems like fflush should take care of this. This is an intro course, so it shouldn't be that difficult.</p>