vendredi 14 octobre 2016

generating random color within an array and storing it in struct

Hi i want to be able randomly select a given set of color and store it into an struct of array.

void addrand(struct inv[],int *ptr)

const char *random[6];
            random[0] = "red";
            random[1] = "green";
            random[2] = "yellow";
            random[3] = "blue";
            random[4] = "white";
            random[5] = "black";

inv[*ptr].color = random[rand()%6];

i get something like array type 'char[30]' is not assignable.




Aucun commentaire:

Enregistrer un commentaire