title: C Programming: How to make program end when user inputs a newline
body: <p>I am building a basic C program that continuously asks users for a string input and prints out the entered input. The program is supposed to exit when a user enters a blank line. However, in my following program, even when I have a conditional that checks whether the user entered a blank line, the program still keeps on going until the user types an input. Below is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main()
  {
      char userString[100];
      while (1 == 1) {
          scanf("%s", userString);
          printf("USER ENTERED %s\n", userString);
          if (userString[0] == '\n') {
              exit(0);
          }
      }
  }
  </code></pre>