0
#include<iostream>
#include<limits>

using namespace std;

struct Player
{
    string name;
    string hometown;
    int age;
    int numGames;

};

int main()
{
    int esportsPlayers;

    cout<<"How many esports players are there at TTU who major in CSC? \n";
    cin>>esportsPlayers;

    
    struct Player* arr=new Player[esportsPlayers];
    int **hours=new int*[esportsPlayers];
    int *totalHours=new int[esportsPlayers];
    
    cout << "Please enter in information about each player: \n\n";
    
    for(int i=0;i<esportsPlayers;i++)
    {
        cout<<"Player "<< i + 1 <<" :\n";
        
        cout << "\tName:\t";        > my issue is that it skips these two lines
        getline(cin,arr[i].name);

        cout << "\tHometown:\t";
        getline(cin,arr[i].hometown);

        cout<<"\tAge:\t";
        cin>>arr[i].age;

        cout<<"\tHow many games does "<<arr[i].name<<" play?\t";
        cin>>arr[i].numGames;
       
        

When the code runs smoothly but the problem is that it skips over where it outputs "Name:" and takes in the user input and goes straight to asking the next line which is asking for the hometown. It does this with every player.

Tommy
  • 1
  • Don't do your own memory handling, use `std::vector` instead. Also,are the hours and total hours part of the player statistics? Then why aren't `hours` and `totalHours` members of the `Player` structure? – Some programmer dude Dec 07 '21 at 09:54

0 Answers0