Change the declaration of the name member inside Player structure form const char *name to char *name. The memory for player's name is allocated dynamically inside team_createPlayer function and the content of the name argument is copied to newPlayer->name. The name variable in the function newPlayer is dealocated. Also, when a player is deleted the memory occupied by it's name is dealocated.
Change the declaration of the
name
member insidePlayer
structure formconst char *name
tochar *name
. The memory for player's name is allocated dynamically insideteam_createPlayer
function and the content of thename
argument is copied tonewPlayer->name
. The name variable in the functionnewPlayer
is dealocated. Also, when a player is deleted the memory occupied by it's name is dealocated.