0

Hi. I have a question about one function in my program. Write a function that will replace players in a tim. New player gets in the game, and takes the place of one that leaves. Prototype of function is:

void replace(TEAM *p,PLAYER newplayer,int num)

where second parameter is new player, and the third is a jersey number of player who leaves the game.
Two structures are defined as:

typedef struct
{
    char name[25],surname[25];int number;
}PLAYER;

typedef struct
{
    char nameofteam[25];int numberofplayers;PLAYER *players;
}TEAM;

First I tried to read which player should get out, but that didnt work:

 printf("which player should get out?\n");
 do
 {
     scanf("%s",p->players.number)
 }
 while(p->players.number);//Choose one of previously read players

Second thing is to read a new player and replace him with the chosen who leaves.

Let me know if you have an idea. Thanks for replies.

2
Contributors
1
Reply
15
Views
2 Years
Discussion Span
Last Post by iamthwee
0

Have some sorta stack. If a player leaves pop them from the stack. Player joins, push them into the empty slot.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.