| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am programming in C++ and have some knowledge of C, but have never been able to solve my problem by using C. I am printing words to the screen and then printing the number of times that they appear in a document. What I am having problems with is aligning everything. I can get all the words aligned away from the left side by using "\t", but since some words are larger than other, using a tab doesn't align everything. I tried using cout.width() and gave it a number. It still does not align all the numbers. I was wondering if there was a way to do print an aligned column to the screen no knowing the previous size of the word, since the cout command is within a for loop. Thanks.
|
|
#2
|
||||
|
||||
|
if you're going to align the text, you're going to have to have at least an idea of what you're upper length is going to be, because there's no way to format previous output to fit the specifications of later output
I'd recommend setting width to the highest value that possibly might occure and set the align to right.... |
|
#3
|
|||
|
|||
|
Quote:
I actually came up with something this afternoon that worked for this example: PHP Code:
this will then space everything evenly. Thanks for the help though. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Formatting outputs to the screen |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|