I have a program that calls a function to generate an array of structures( data_set ). The structures consist of a char[20] and 2 int data types. Now what I'm trying to do is randomly pick from an enumerated data type and here is the code I have with a comment where my problem is:
// enumerated data type
enum datalist
{
complete,
considering,
active,
// and 27 others but you get the point
};
// structures
struct data_set
{
char status[20];
int priority;
int complexity;
};
// declarations
enum datalist status_type,*ptrlist; // I imagine I'll need a pointer
struct data_set set1[30];
// implementation
srand(time(NULL)); // for random picking from data list
for(int i=0;i<30;i++)
{
random_number=rand()%30; // to get a number from 0 to 29
// this is where I am having trouble, I know the enum datalist counts
// ...complete as 0, considering as 1, and so on. However, I've tried
// ...many ways to take my random_number and make it point to one
// ...of the enumerated data types, but I usually wind up with a
// ...conversion error, non lValue, forward declaration, and others.
set1[i].status=s; // put randomly picked status_type in struct set1
}
It's probably something simple that I'm not seeing. Hope this code isn't too hard to read, I'm still learning. Oh, and if you see any bad habits or form in this, please let me know.
Thanks,
Auto aka Servo