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 derfloh 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
Joined
Apr 25, 2001
Messages
2,218
Location
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 ...
 
Thanks, I'll try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top