mercredi 26 octobre 2022

Pick one string from an Array of 4 strings in C [duplicate]

I have this kind of array with these values declared in this way :

static char forecast[4][150] = {"Sunny","Cloudly","Heavy rain", "Ice"};

now, I want to pick up randomly one string among the other and to do this I did this:

        forecast = forecast[rand()%4];

but I'm receiving this error:

error: assignment to expression with array type

What's wrong with my code?

Thanks for the answer.




Aucun commentaire:

Enregistrer un commentaire