title: C: Using scanf to accept a predefined input length char[]
body: <p>I'm writing a C program that needs to accept user input of up to 100 characters, but the user is allowed to input less than that limit. I'm trying to implement this idea with a while loop that continues to accept char input until the user presses enter (ascii value of 13), at which point the loop should break. This is what I've written:</p>
  
  <pre><code>char userText[100]; //pointer to the first char of the 100
  int count = 0; //used to make sure the user doens't input more than 100 characters
  
  
  while(count&lt;100 &amp;&amp; userText[count]!=13){ //13 is the ascii value of the return key
      scanf("%c", &amp;userText[count]);
      count++;
  }
  </code></pre>
  
  <p>Launching from the command line, if I enter a few characters and then press enter, the prompt simply goes to a new line and continues to accept input. I think the problem lies with my lack of understanding how scanf receives input, but I'm unsure of how to change it. What can I do to make to loop break when the user presses enter?</p>