title: Printf variable number of decimals in float
body: <p>I found interesting format for printing nonterminated fixed length strings like this:</p>
  <pre><code>char newstr[40] = {0};
  sprintf(newstr,&quot;%.*s&quot;,  sizeof(mystr), mystr);
  </code></pre>
  <p>So I think maybe is there a way under printf command for printing a float number...</p>
  <blockquote>
  <p>&quot;%8.2f&quot;</p>
  </blockquote>
  <p>to have ability to choose number of decimals with integer number.</p>
  <p>Something like this:</p>
  <pre><code>sprintf(mystr, &quot;%d %f&quot;, numberofdecimals, floatnumbervalue)
  </code></pre>