I have to model the periodic table in C, for an educational software project (It's basically a quiz).
I already created a struct and declared all the elements. Now I have to write a function that chooses one element randomly.
This is my struct:
typedef struct{
        char name[15];
        char shortname[3];
        int group;
        int period;
}element;
element hydrogen={"hydrogen", "H", 1, 1}, helium={"Helium", "He", ...
I already tried to combine them in an array, to then generate a random index:
element elements[118];
elements[1] = {"hydrogen", "H", 1, 1};
but that just gave me errors :(
Any ideas?
 
     
     
    