Creating Table headers?
<p>OK, in this program I am required to make a table based of user input. The problem is I cannot figure out how to get the table headers to properly align with the information that is displayed. The table headers would not line up from lets say if the user enters in Michael for player one and Michael Jordan for player 2. Any advice to allow the headers to properly align with the displayed input regardless of character length would be greatly appreciated, thanks.</p>

<p>Here is my code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;
#include &lt;cstdlib&gt;
using namespace std;


//struct of Basketball Player info
struct BasketballPlayerInfo
{
    string name; //player name

    int playerNum, //player number
        pointsScored; //points scored

};

int main()
{
    int index, //loop count
        total = 0; //hold total points
    const int numPlayers = 5; //nuymber of players
    BasketballPlayerInfo players[numPlayers]; //Array of players

    //ask user for Basketball Player Info
    cout &lt;&lt; "Enter the name, number, and points scored for each of the 5 players.\n";

    for (index = 0; index &lt; numPlayers; index++)
    {
        //collect player name
        cout &lt;&lt; " " &lt;&lt; endl;
        cout &lt;&lt; "Enter the name of player # " &lt;&lt; (index + 1);
        cout &lt;&lt; ": ";

        //input validation
        if(!(getline(cin, players[index].name)))
        {
            cout &lt;&lt; "Player Name must be alphabetical characters only!\n";
            cout &lt;&lt; "Program terminating please start over." &lt;&lt; endl;
            system("pause");
            exit(0);
        }

        //getline(cin, players[index].name);

        //collect players number
        cout &lt;&lt; "Enter the number of player # " &lt;&lt; (index + 1);
        cout &lt;&lt; ": ";

        //input validation
        if(!(cin &gt;&gt; players[index].playerNum))
        {
            cout &lt;&lt; "Player Name must be numeric characters only!\n";
            cout &lt;&lt; "Program terminating please start over." &lt;&lt; endl;
            system("pause");
            exit(0);
        }
        //collect points scored
        cout &lt;&lt; "Enter points scored for player # " &lt;&lt; (index + 1);
        cout &lt;&lt; ": ";

        //input validation
        if(!(cin &gt;&gt; players[index].pointsScored))
        {
            cout &lt;&lt; "Player Name must be numeric characters only!\n";
            cout &lt;&lt; "Program terminating please start over." &lt;&lt; endl;
            system("pause");
            exit(0);
        }

        cin.ignore();
    }

    //display
    cout &lt;&lt; "\n";
    cout &lt;&lt; "Here is the information for each player: \n";
    cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2);
    cout &lt;&lt; "\n";
    cout &lt;&lt; "          \tName\tNumber\tPoints\n";
    cout &lt;&lt; "------------------------------------------------" &lt;&lt; endl;

    for(index = 0; index &lt; numPlayers; index++)
    {
        cout &lt;&lt; "Player # " &lt;&lt; (index + 1);
        cout &lt;&lt; ": \t" &lt;&lt; players[index].name &lt;&lt; "\t" &lt;&lt; players[index].playerNum &lt;&lt; "\t" &lt;&lt; players[index].pointsScored &lt;&lt; endl;
        cout &lt;&lt; "------------------------------------------------" &lt;&lt; endl;

    }

    //display total points scored by all players
    for(index = 0; index &lt; numPlayers; index++)
    {
        //hold total
        total += players[index].pointsScored;
    }

    cout &lt;&lt; "Total Points scored are: " &lt;&lt; total &lt;&lt; endl;

 system("pause");
return 0;

}
</code></pre>
