Here is my problem

I have a league system, however to input a teams score, I select the team via input of an int ID number (int) however I need to enter a the Team name (String) from the array.

I cannot get it to work.

Can someone please help me http://www.gidforums.com/images/gid/smilies/icon_smile.gif

Here is the part of the code that does this part:

int take_team_input()
{
        char team[16];



        int ID = 0;
        int player1 = 0;

        int player2 = 0;

        int score1 = 0;

        int score2 = 0;

        int i;



        printf("\n%2s %-16s\n","ID","Team Name");




        //records home and away team ID and score

        for (i = 0; i < num_teams; ++i)

        {

                strcpy(team, arrdetails[i].team);

                ID = arrdetails[i].ID;

                printf("%2d %-16s\n", ID, team);

        }



                printf("\nInput Home Team ID\n>");

                scanf("%d", &player1);

                printf("\nEnter their Score\n>");

                scanf("%d", &score1);

                printf("\nInput Away Team ID\n>");

                scanf("%d", &player2);

                printf("\nEnter their Score\n>");

                scanf("%d", &score2);



        // points for a draw

        if (score1 == score2)

        {

        arrdetails[player1].played++;

        arrdetails[player2].played++;

        arrdetails[player1].goalsf = arrdetails[player1].goalsf + score1;

        arrdetails[player2].goalsf = arrdetails[player2].goalsf + score2;

        arrdetails[player1].goalsa = arrdetails[player1].goalsa + score2;

        arrdetails[player2].goalsa = arrdetails[player2].goalsa + score1;

        arrdetails[player1].drew++;

        arrdetails[player2].drew++;

        arrdetails[player1].points++;

        arrdetails[player2].points++;

        }

There is a lot more code to this however this is the relevant part to which I am extremely stuck on.

Any help or pointers would be greatly appreciated :)

just use fgets() to get the team name from the keyboard. You are experienced enough to have written all that complex code so surely you should be able to easily figure out how to use a simple function like fgets().

I've done java at the same time so that's how I figured out the above however I've not covered fgets() but I'll look into that now
Thanks mate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.