Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

graduated printing

Status
Not open for further replies.

marsd

IS-IT--Management
Apr 25, 2001
2,218
US
I would like to be able to format my printing
dynamically:
example:

for (x=10 ; x > 0 ; x--) {
if (x < prev) {
printf &quot;%(x + 1)d&quot;, x
}
prev = x
}

of course this doesn't work.
What is the syntax that I need for this?

TIA
 
You can try:

for (x=10 ; x > 0 ; x--) {
if (x < prev) {
Format = &quot;%&quot; x + 1 &quot;d&quot;;
printf Format, x;
}
prev = x
}

The idea is to build the Format string outside of the printf command ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top