title: Segmentation fault in c when reading a line
body: <p>I want to read user input(like terminal) until exit is written or <kbd>ctrl</kbd>+<kbd>c</kbd>/<kbd>ctrl</kbd>+<kbd>d</kbd> is pressed.  I read every line(until return/enter is pressed), check if it's just space or a comment(#) and then execute some functions.</p>
  
  <p>I tried three methods, but no success. I get an error every time I insert a string and press enter</p>
  
  <pre><code>char line[256];
  while(printf("%s&gt;", shell_name) &amp;&amp; scanf("%50[^\n]", line) != EOF)
  {
  </code></pre>
  
  <p>Segmentation fault (core dumped)</p>
  
  <pre><code>while(printf("%s&gt;", shell_name) &amp;&amp; getline(line, 100, stdin) != EOF)
  </code></pre>
  
  <p>note: expected ‘size_t * <strong>restrict</strong>’ but argument is of type ‘int’</p>
  
  <pre><code>while(printf("%s&gt;", shell_name) &amp;&amp; fgets(line, sizeof(line), stdin) != NULL)
  {
  </code></pre>
  
  <p>Segmentation fault (core dumped)</p>
  
  <p>for more orientation I'm doing this next </p>
  
  <pre><code>if(isspace(&amp;line) == 0 &amp;&amp; &amp;line[0] != "#")
  </code></pre>
  
  <p>what am i doing wrong? is there a more suitable/easy/better option?</p>