title: sprintf usage with %.s
body: <p>While using sprintf like this</p>
  
  <pre><code>sprintf("%.40s",str);
  </code></pre>
  
  <p>I want to give a value like strlen(str) in place of 40.How do I do that? I tried replacing 40 with strlen(str), doesn't work. Giving a value like</p>
  
  <pre><code>#define len strlen(str)
  </code></pre>
  
  <p>and using %.len doesnt work either since %.len is used in "  ".</p>