title: User string input to go until \0 in c
body: <p>I am trying to simply get a user input string. The string is saved (scanf) when the person hits enter or the string hits the NULL character. Yet, when I run my program, and type in the string, it continues input until I type \n or \0 (whichever I have in my if statement. Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define MSL 30
  
  char intersperse(char);
  char widen_stars(char);
  
  int main(int argc, char *argv[])
  {
      char *p, *q, *str1[MSL], *str2[MSL];
  
  
      if(str1[MSL+1] != '\0'){    
      printf("Please enter a string of maximum 30 characters: ");
      scanf("%s\n", str1[MSL]);
  
  
      }
      printf("%s\n", str1[MSL]);
  
  }
  </code></pre>
  
  <p>This is by no means finished code, i'm just in the process of writing my program when I snagged this annoying bug. The +1 on my MSL is to make sure the NULL character is read so my string doesn't yell at me, idk if it's necessary, but it's a precaution. Thank you answerers.</p>