Variable column widths, string lengths in printf-style functions

topic: 

I have been programming in C for quite some time, but until recently I was not aware that you could specify column widths and string limits using variables. I have neither seen this functionality used in any projects until I started working with OpenSER.

Specify a variable column width:

printf("%*d", width, number);

Specify a variable number of characters from a string:

printf("%.*s", width, string);

Comments

Can you please post a link to document explaining this feature

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.