title: ' ', '\n' , scanf() and output screen
body: <p>I wrote the following code to accept characters from user and enter into an array till he inputs a free space (' ') or a line <code>\n</code>. But code is not functioning. As in, when space bar or return key is pressed in the input, my computer is still accepting values without exiting the loop.</p>
  
  <pre><code>char X[99];
  printf ("Type the string without spaces\n");
  for (i=0;i&lt;99;i++) {
    scanf ("%c",&amp;m);
    if(m!=' '&amp;&amp;m!='\n')
      X[i]=m;
    else i=99;
    }
  </code></pre>
  
  <p>Please explain the error.</p>