Hi,
I'm having a problem centering variable data thats being printed to the screen. Since the text im using is different from the variables.
Now i have a function that centers strings. But when i try to print out a variable on the right side of the string it centers the string and the variable stays to the right of it, and if i try to pad the string to make it move more to the left it doesn't move the string to the left and only makes the variable information shift to the right.
(centered string) (Variable Printed)
With Padding
(centered string)-------------------->(Variable Printed)
When I want the whole group moved left with no big space in between.
1 2 3 4 5 6 7 8 9 10 11 12
|
void centerstring(char*s)
{
HANDLE hOut;
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD NewSBSize;
NewSBSize = GetLargestConsoleWindowSize(hOut);
int l=strlen(s);
int pos=(int)((NewSBSize.X-l)/2);
for(int i=0;i<pos;i++)
cout<<" ";
cout<<s;
}
| |
1 2
|
centerstring("Registered To: "); cout << RegisteredToName; cout << "\n";
centerstring("Account Type : "); cout << RegisteredType; cout << "\n";
| |
Essentially what i want is a Left Aligned Centered
I want text centered. Then the text to all be in a straight line on the left side of that center.
[---------------TEXT HERE---------------]
[----------BIGGER TEXT HERE----------]
Like this:
[---------------TEXT HERE---------------]
[---------------BIGGER TEXT HERE-----]
And to be able to control the padding without messing up the variable print.