Is there (are there?) manipulators out there that will accomodate different size strings yet keep a 'centered' format.
Here's the deal...I want to use a loop to output different variables, some of which are strings (actually, char arrays) and these are different sizes, in a perfect world all names would be the same length. Unfortunately, this is not so. Anyway I'm using basic output manipulators...ie. setw() and the like...to space items out. Is there a center align tag to implement?
Thanks in advance to any help. I would have included code if I thought it was relevant.
I've looked in 3 different books for a resolution to this problem, just didn't want anybody to think I was lazy. Perhaps a little dyslexic as I couldn't find the problem....
I don't know of any formatting tags that would help you attain the desired effect (but I'm as far from an authority on the subject as you can get). I would say as an option though, that it would be relatively easy to write a function that...
A) Counts the number of characters in your string
B) Deducts that number from the console width (80?)
C) Divides whatever's left by 2 giving a number X
D) prefixes and appends your string with X number of spaces before returning it for output.
This should in effect give you a string that will be centred so long as it prints on a new line.
i wouldn't append the spaces, then if the console is 79, then it will double space it. just prefix it.
lol, of course, my bad :) Well spotted Inquirer
I have yet to implement it, but I may be able to setf() and then right/left justify my way into readable format. If anybody else has a suggestion or better way, I'd appreciate it.