title: Beginning C program freezing at scanf
body: <p>I'm having a problem with scanf freezing. I've looked around and while some questions are similar, they haven't helped in solving my problem.</p>
  
  <pre><code>main(int argc, char **argv) {
  //FILE *stream = stdin;
  if (stdin == NULL) {
      printf("Could not open file");
      return 0;
  }
  int exists = 0;
  char letter;
  char next = 'H';
  char word[30];
  int frequency = -1;
  int sample = -1;
  char  *channels;
  channels=malloc(sizeof(7*sizeof(char)));
  int bitres = -1;
  int secondE = 0;
  
  
  while (exists == 0) {
      scanf("%c", &amp;letter);   //this is the problem, possibly scanf
      printf("AFTER");
      if (letter == EOF) {
      //  printf(letter);
          printf("HEADER NOT DETECTED");
          return 0;
      }
  </code></pre>
  
  <p>I've pinpointed the problem using printf. I'm currently piping in another file through command prompt into this program. When I reach scanf it just hangs. If anyone knows the solution I would be very thankful.</p>
  
  <p>On a side note, is using scanf bad practice? It's just as easy to assign stdin to a file pointer (I actually have this commented out) but scanf  seemed just as easy.</p>