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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to a particular spot on a line in C++

Status
Not open for further replies.

hookook

MIS
Jul 8, 1999
2
US
Help!!!<br>
<br>
I want to have my data starting printing on space 30 in the line but cout does not appear to have any options to start at a particular space on a line. Any suggestions?<br>
<br>
<br>
Chuck
 
How about this:<br>
<br>
int spaces = 30;<br>
<br>
for (int i=0;i&lt;spaces;i++) cout &lt;&lt; " ";<br>
<br>
cout &lt;&lt; yourString &lt;&lt; endl;<br>
<br>
-Mart311
 
There are a lot of ways you can do that. There is a funtion called memset(). You just set a buffer with 30 spaces and print it .<br>
<br>
For eg,<br>
memset(buffer, ' ', 30) ;<br>
cout&lt;&lt; buffer;<br>
Does it answer your question ?<br>
Thanks<br>
Siddhartha Singh<br>
<A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A><br>

 
well, if you use the iomanip library
setw(30) will work just fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top