Pass enum to function in C?

I have for example this

enum Resource { ROCK = 1, PAPER = 2, SCISSORS= 4};

how shall I pass that to a function like

void* player(void* av, enum Resource r) {
....
}

but instead I just want void* av as the only parameter for player

throughout the player function I only used r, but not specifically ROCK, PAPER or SCISSORS

How can I achieve that without needing to pass enum Resource r as a parameter?

Comments

  • I don't understand your question. What is void* av to you and how do you want to use the enum?

  • Your last sentence seems to be the only one that I can answer, you can just put r in file scope or global scope... if this function is actually a method you can just make r a private member of the class your method belongs to.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion