Want to shuffle char *array and make elements random order
I read Shuffle array in C but for int
I try
const char *words = { "one", "two", "three", "four", "five", "six" };
for (int i=0; i<6; i++)
{
int r = (rand() % (6 - i)) + i;
int temp = words[i];
words[i] = words[r];
words[r] = temp;
}
error though when iterate array words
please explain
Aucun commentaire:
Enregistrer un commentaire