Something goes wrong with arrays of structs (C)

This is my code . It goes well if I add just one player but after the first cicle ends and it asks (in italian ) what i wanna do if I give as input 1 it let me create a new player asks for the name and the lastname , but after it asks for the role type it blocks and it exits from the code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 25

struct rol{
    int position;
    int lato;
};
typedef struct rol role;

struct pl{
    role *ruol;
    int shirt_num;
    char name[20];
    char lastn[20];
};
typedef struct pl player;

struct tm{
    int classpos;
    int pnt;
    player players[MAX];
};


typedef struct tm team;

void define_role (role *ruolo);
void make_pl(player *pl);
void print_pl(player *pl,int i,role *x);
int main(int argc, char** argv) {
    int risp,i;
    player *giocatore;
    int cont = 0;
    printf("Vuoi effettuare lavori su un giocatore o su una squadra ? \n [ 1) giocatore  2)  squadra] ");
    scanf(" %d",&risp);

    if(risp==1) {
        do {
            printf("\n\n1)Crea Giocatore \n 2)Modifica giocatore \n3)Inserisci giocatore in una squadra");
            printf("\n 4)Visualizza dati giocatore \n 5) Finish program");
            scanf(" %d",&risp);
            if(risp==1) {
                cont++;
                giocatore = (player*)malloc (cont*sizeof(player));
                if (giocatore== NULL) { 
            printf("Memory not allocated.\n"); 
            exit(0); 
            } 
                giocatore->ruol = (role*)malloc(cont*sizeof(role));
                if (giocatore->ruol== NULL) { 
            printf("Memory not allocated.\n"); 
            exit(0); 
            } 
                make_pl(&giocatore[cont-1]); //this is the main problem basically 
            }

            } while(risp != 5);
    }
    return 0;
}

void make_pl(player *pl) {
    printf("\n Inserisci nome ");
    scanf(" %s",pl->name);
    printf("\n Inserisci cognome ");
    scanf(" %s",pl->lastn);
    define_role(pl->ruol);
    printf("Inserisci numero di maglia ");
    scanf(" %d",&pl->shirt_num);
} 

void define_role(role *ruolo) {
    printf("\n Inserisci lato ");
    scanf("%d",&ruolo->lato);
    printf("\n Inserisci posizione ");
    scanf("%d",&ruolo->position);
}

this is what it show as output :

Vuoi effettuare lavori su un giocatore o su una squadra ? 
 [ 1) giocatore  2)  squadra] 1


1)Crea Giocatore 
 2)Modifica giocatore 
3)Inserisci giocatore in una squadra
 4)Visualizza dati giocatore 
 5) Finish program 
1

 Inserisci nome bobby

 Inserisci cognome solo

 Inserisci lato 0

 Inserisci posizione 1
Inserisci numero di maglia 15


1)Crea Giocatore 
 2)Modifica giocatore 
3)Inserisci giocatore in una squadra
 4)Visualizza dati giocatore 
 5) Finish program
1

 Inserisci nome robert

 Inserisci cognome idunno

 Inserisci lato 1

RUN FAILED (exit value 1, total time: 45s)

So the basic problem is i cant save more than one player im kinda disperate i dont know what’s the problem .

Have you tried running with Valgrind? That’s the best way to find the source of these sorts of memory errors.

I’m not 100% sure, but it looks like an issue in your allocation of the memory for the role. At the very least, that allocation should be in the loop if(risp==1).

Also, don’t forget to deallocate your memory when your program exits!

I think you want to be using the team struct instead of making a new player array and then allocating player structs in the team->players array. Also, you probably want to store the total number of players in the team struct.