mercredi 24 mai 2017

How to randomly pick elements from an array in C?

I have an array of 5 rows and 20 columns :

char name[6][20];

And I enter the names with for :

puts("Enter with 6 names :");

for(i=0; i< 6 ; i++)
{
   scanf("%19[^\n]%*c",name[i]);
}

After that, I need to randomly choose three names of the array and display them in the screen. How can I do that ?

PS : Different from the other questions similar to that, I want not to take just one word, but the full word of the array.




Aucun commentaire:

Enregistrer un commentaire