Re: Printf puzzlement

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi, another way

printf(1, "%7.7s", {string})

will print the string into an allocation of 7 spaces, clipped to a maximum of 7 characters, so

1234567

printf(1, "%7.3s", {string})

123

and printf(1, "%-7.3s", {string})

123

the '-' sign says to justify to the left, and the number after the decimal point says how many characters to print within the allocated space. The allocated space can be overflowed, so just watch for that.

Cheers

Chris

Sorry, just noted that that justification didn't show properly

printf(1, "%7.7s", {string}) 
 
will print the string into an allocation of 7 spaces, clipped to a maximum of 7 characters, so 
 
1234567 
 
printf(1, "%7.3s", {string}) 
 
    123 
 
and 
printf(1, "%-7.3s", {string}) 
 
123 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu