For some reason I am not able to access procNames.count. All I need to do is increment the counter. I am not sure why. Anyone sees the problem?
struct config_line {
char name[MAX_WORD];
int time;
};
struct config {
struct config_line *lines;
int count;
};
//global variable
struct config configData;
// allocate memory to procNames
procNames = malloc(sizeof(struct config));
if ( procNames == NULL ) {
printf("problem allocating memory, for procNames. int procnanny(void)");
return 0;
}
//local variable
struct config *procNames;
procNames = &configData;
// the problem
procNames.count++;
Use:
procNamesis a pointer, so you need to use that or the long-winded:You can only use the
.operator when the value on the LHS is a structure. When you have a pointer to a structure, you have to either use->or dereference the pointer and then apply the.operator, which requires parentheses as well as the*because.binds tighter than unary (dereferencing)*.