My goal is to access max_resources_per_client[1][1]
.
In conf.c
that can't be modified, I got:
#define NUM_CLIENTS 5
#define NUM_RESOURCES 3
const unsigned int num_clients = NUM_CLIENTS;
const unsigned int num_resources = NUM_RESOURCES;
const unsigned int max_resources_per_client[NUM_CLIENTS][NUM_RESOURCES] = {
{7, 5, 3},
{3, 2, 2},
{9, 1, 2},
{2, 2, 2},
{4, 3, 3},
};
In my file main.c
I have:
extern const unsigned int num_clients;
extern const unsigned int num_resources;
extern const unsigned int **max_resources_per_client;
How can I access max_resources_per_client[1][1]
without causing a segmentation fault?
Note: Trying to do
extern const unsigned int max_resources_per_client[num_clients][num_resources];
results in an error: variably modified ‘max_resources_per_client’ at file scope
Note: Trying to do extern const unsigned int max_resources_per_client[NUM_CLIENTS][NUM_RESOURCES];
results in error: NUM_RESOURCES’ undeclared here (not in a function)