I have a function which sets a variable based on another variable.

```
if(!button_x.on)
   button_x.on = 1;
if(!button_y.on)
   button_y.on = 1;
if(!button_z.on)
   button_z.on = 1;
.
.
.

```

If it is x, y, z, …. is determined only at runtime. Having multiple such conditions for various(100s) different cases does not look good. Is there a better way to go about this in C?

---

EDIT:
I should have better framed my example above.

```
if (!structureA.visited)            
    visit_structureA(); // does some operation
if (!structureB.visited)            
visit_structureB();
if (!structureC.visited)            
visit_structureC();

```

.
.
.

The number of structures and the name of the structure is not known at compile time. But the structure names follow a specific pattern shown above. It is known only at runtime. 
I tried using macros something like:

```
#define VISIT(str) \
    if (!structure##str.visited) \
        visit_structure##str();

//In the function:
// str = 'known at runtime' 
  VISIT(str);

```

But this would not work for obvious reason that preprocessor directives are replaced during compile time and not runtime. I am not sure if there is a better way for this?