vendredi 29 mai 2015

Using realloc for dynamic array Array **

(C question) Hi, I tried to extend my fully list of players. When i use the realloc function, it save my first player but not any other of the list. I mean that in the and of the realloc i got just one (Player *pl) in the list. this is part of the function:

void initializeListForTree(Player** players, int listSize)
{
    int formulaSize = bla bla bla.....
    players = (Player **)realloc(players, sizeof(Player *)*formulaSize);
    if (!players)
    {
        printf("memory allocation failed\n");
    }
}

Aucun commentaire:

Enregistrer un commentaire