title: Adding values from a file to an array until a certain character
body: <p>I am working on a program that uses file redirection to read in a file, read one character per line until I reach a '0', store the characters in an array , and sort that array (from largest to smallest). Anyway, I really only need help with reading the characters until the zero shows up. Below is the text file that I am reading in:</p>
  
  <pre><code>f
  k
  s
  j
  p
  a
  v
  r
  t
  u
  h
  m
  g
  e
  b
  y
  n
  z
  w
  l
  i
  x
  q
  c
  o
  d
  0
  </code></pre>
  
  <p>Below is the code I have so far:</p>
  
  <pre><code>int main(void)
  {
      int i=0;
      char array[100];
  
      while(fscanf(stdin, "%c", &amp;array[i]) &amp;&amp; array[i]!='0')
      {
          i++;
      }
  
      int N = (sizeof(array)/sizeof(array[0]));
  
      for(i=0;i&lt;N;i++)
      {
          printf("%c", array[i]);
      }
  
  return(0);
  }
  </code></pre>
  
  <p>When I run this program, it prints out every line of the file, including the zero. It also prints out some really weird characters after the zero (using gcc compiler). What am I doing wrong?</p>