I would like to define a global/public variable that is created by struct. I can not access user_list.x or y/z inside the main or any another function. when I debug the code below, I get the following error “request for member ‘x’ in something not a structure or union”. How can I declare a global struct variable that I can access from different functions? Thank you
#include <stdio.h>
#include <stdlib.h>
struct routing {
int x;
int y;
int z;
};
struct routing user_list[40];
int main(int argc,char *argv[])
{
user_list.x = 1;
printf("user_list.x is %d",user_list.x);
return 0;
}
You are using an array of
structobjects not astructobject.Specify the array member you want to access: