title: Handling of %s by printf function in C
body: <p>When I use the lines:</p>
  
  <pre><code>char *sentence = (char *)malloc(100);
  scanf("%[^\n]%*c",sentence);
  </code></pre>
  
  <p>to read a line from stdin into the buffer, sentence, but then have:</p>
  
  <pre><code>printf("%s\n", sentence);
  </code></pre>
  
  <p>afterwards, I notice that printf prints the entire sentence as opposed to just the first word from the line. Why is this? Shouldn't printf take only up to the first white space? If not, how does it know where to stop? Sentence surely doesn't end in a "\n" since it doesn't read the last return, and we used *c to read one character and not store it.</p>