title: Using sscanf on buffer with new line characters: how to read all lines?
body: <p>In C, how can I use sscanf over a buffer that contains new line character.</p>
  
  <p>Example buffer:</p>
  
  <pre><code>buf = "Name: Sam\nID: 123\nLocation: 123\nDest: abc\0";
  </code></pre>
  
  <p>I want to do something like:</p>
  
  <pre><code>sscanf(buf, "%[^\n]s\n%[^\n]s\n%[^\n]s\n%[^\0]s", line1, line2, line3, line4);
  </code></pre>
  
  <p>but <code>sscanf</code> is only picking line1. Any ideas on how to make this work.</p>
  
  <p>NOTE: I would really like to avoid looping over the buffer 4 times which can be a possible solution.</p>