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!

How to printf string starting in column 42.

Status
Not open for further replies.

SkiLift

Programmer
Dec 18, 2003
47
US
I have a string that can be from 1 to 40 chars in length. I want to start printing in column 42. I cant figure out how to do it. The following ends in column 42. Is there a way to do this? Do I have to print out 41 spaces first?

Code:
printf("%42.40s\n", "Open DB no. 1");
yields:
                             Open DB no. 1
                                         ^
                                         col 42
 
Try:

Code:
printf("%41c%s\n",' ',"Open DB no. 1");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top