c
Variable column widths, string lengths in printf-style functions
By Vadim - Posted on April 6th, 2007
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);
Recent comments
1 week 20 hours ago
2 weeks 1 day ago
3 weeks 1 day ago
3 weeks 2 days ago
3 weeks 5 days ago
3 weeks 6 days ago
4 weeks 3 days ago
4 weeks 4 days ago
4 weeks 5 days ago
4 weeks 5 days ago