title: scanf in a loop till carriage return
body: <p>I am trying to read user input with multiple fields. But the number of fields is not specified. I want to read all the words till the carriage return. i tried this code but it isnt working:</p>
  
  <pre><code>char str[256];
  while(1)
  {
      scanf("%s", str);
      if(str[strlen(str)] == '\n')
           break;
      else
           printf("Got %s\n", str);
  
  }
  </code></pre>
  
  <p>Examples of user input:<br>
  1. store file1<br>
  I need to parse store and file1 and break out of the loop.<br>
  2. store file1 file2<br>
  I need to parse store, file1 and file2 and break out of the loop.   </p>
  
  <p>Wondering how to break out of the loop at the carriage return. </p>
  
  <p>thanks. </p>