title: While loop asking for input until ctrl-d using C
body: <p>I want to make a while loop that is continually asking a user for input until the user <kbd>ctrl</kbd>-<kbd>d</kbd>'s out of it. How can I do this correctly? I am using this right now:</p>
  
  <pre><code> while (1)
      {
          printf("Enter host name: ");
          fgets(user_input, 1000, stdin);
      }
  </code></pre>
  
  <p>This works, except the user has to hit <kbd>ctrl</kbd>-<kbd>c</kbd> to end the program. I am wanting to continually ask the user for his input until he/she hits <kbd>ctrl</kbd>-<kbd>d</kbd>. How can I do this?</p>