I have a basic problem. I should know enough about pointers by now. The way I see it configData is the first link in a linked list (of the type struct config) while procNames is a pointer to the first link in a linked list of the type struct config. So if I want to say that procNames is equal to configData then I need to access the pointer that points to configData which is *configData. Anyhow I think I am missing something. Anyone sees the problem? Also, I get the next error: error: invalid type argument of unary ‘*’ (have ‘struct config’)
struct config_line {
char name[MAX_WORD];
int time;
};
struct config {
struct config_line *lines;
int count;
};
//global variable
struct config configData;
//local variable
struct config *procNames;
//the problem (done locally)
procNames = *configData;
I think you want
This sets the pointer
procNamesto the address of the structureconfigData.You can access the elements using either
or
Remember that, since
linesis itself a pointer, you’ll need to allocate memory for eachconfig_linestructure:or