title: Detecting Ctrl-D in C
body: <p>I am trying to detect the <kbd>Ctrl</kbd>+<kbd>D</kbd> user input, which I know returns <code>EOF</code>. Right now, I know the code waits for input from the stdin stream, but is there a way to let the program continue until the <kbd>Ctrl</kbd>+<kbd>D</kbd> command is in stdin? The program should continue running past the if statement if <kbd>Ctrl</kbd>+<kbd>D</kbd> isn't inputted.</p>
  
  <pre><code>char buffer[];
  if (fgets(buffer, 10, stdin) == NULL{
      //write to file
  }
  </code></pre>