IOMANIP Help! Alligning character symbols

I have a function here that is suppose to output the character sign "*" in a perfectly aligned manner. My probem is that when row 10 starts, my stars shift one unit to the right. Notice, on row 10 and furthermore, it only shifts on "A" but on bcde they're perfectly aligned. Can someone please help me how to fix this issue?


      a   b   c   d   e
Row1  *   *   *   *   *
.
.
.
.
Row10  *  *   *   *   *
Row11  *  *   *   *   *
Row12  *  *   *   *   *
Row13  *  *   *   *   *



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  void seat_open(char seats[][5],int seatsize)
{
	//Display seat number
	cout<<" "<<"\tA\t"<<"B\t"<<"C\t"<<"D\t"<<"E\t";
	cout<<"\n\n";
	int row=0;
	int col=0;
	for(row=0;row<seatsize;row++)
		{
			cout<<"Row " <<row+1;
		
				
					
			cout<<right;
			cout<<setw(7);
					
			for(col=0;col<5;col++)
			{
			
				seats[row][col]='*';
				cout<<seats[row][col];
				cout<<"\t";
			}
			cout<<endl;
		}

}
You could align "Row" to the left.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iomanip>
#include <iostream>
#include <string>

int main()
{
    for (int i=0; i < 20; ++i)
    {
        std::cout << std::setw(10);
        std::cout << std::left << "Row " + std::to_string(i) << "*\n";
    }
}
Row 0     *
Row 1     *
Row 2     *
Row 3     *
Row 4     *
Row 5     *
Row 6     *
Row 7     *
Row 8     *
Row 9     *
Row 10    *
Row 11    *
Row 12    *
Row 13    *
Row 14    *
Row 15    *
Row 16    *
Row 17    *
Row 18    *
Row 19    *
Catfish, I did do that currently but I'm still getting the star one unit to the right on row 10,11,12...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void seat_open(char seats[][5],int seatsize)
{
	//Display seat number
	cout<<" "<<"\tA\t"<<"B\t"<<"C\t"<<"D\t"<<"E\t";
	cout<<"\n\n";
	int row=0;
	int col=0;
	for(row=0;row<seatsize;row++)
		{
			cout<<left<<setw(2);
			cout<<"Row " <<row+1;
			
					
			for(col=0;col<5;col++)
			{
				cout<<right<<setw(5);
			
				seats[row][col]='*';
				cout<<seats[row][col];
				cout<<"\t";
			}
			cout<<endl;
		}

}
In the code below I left-aligned starting from row+1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iomanip>
#include <iostream>

using namespace std;

void seat_open(char seats[][5],int seatsize)
{
    //Display seat number
    cout<<" "<<"\tA\t"<<"B\t"<<"C\t"<<"D\t"<<"E\t";
    cout<<"\n\n";
    int row=0;
    int col=0;
    for(row=0;row<seatsize;row++)
        {
            cout<<"Row ";
            cout << setw(5) << left << row+1;
                    
            for(col=0;col<5;col++)
            {
                //cout<<right<<setw(5);
            
                seats[row][col]='*';
                cout<<seats[row][col];
                cout<<"\t";
            }
            cout<<endl;
        }

}

int main()
{
    char seats[20][5];

    seat_open(seats, 20);
}
Thank you Catfish :)
Topic archived. No new replies allowed.