mardi 30 décembre 2014

Generate random string for member of struct

I would like to know how I can generate a random string for a member of a struct and assign this value to the member of the struct.


My struct is defined this way:



struct student{
int key;
char name[25];
}


I already generated random numbers of the member "key" of struct.

Part of the code of the method:



struct student s;
int r = rand() % 5000;
s.key=r;


Note: With srand(time(NULL)); defined in main().


How I do it for s.name?





Aucun commentaire:

Enregistrer un commentaire