title: How do you print a limited number of characters?
body: <p>Sorry to put a post up about something so simple, but I don't see what I'm doing wrong here.</p>
  
  <pre><code>char data[1024];
  DWORD numRead;
  
  ReadFile(handle, data, 1024, &amp;numRead, NULL);
  
  if (numRead &gt; 0)
      printf(data, "%.5s");
  </code></pre>
  
  <p>My intention with the above is to read data from a file, and then only print out 5 characters. However, it prints out all 1024 characters, which is contrary to what I'm reading <a href="http://www.cplusplus.com/reference/clibrary/cstdio/printf/" rel="noreferrer">here</a>. The goal, of course, is to do something like:</p>
  
  <pre><code>printf(data, "%.*s", numRead);
  </code></pre>
  
  <p>What am I doing wrong here?</p>