I have enum in header file.
typedef enum{
up = 8, down = 2, left = 4, right = 6
}direction;
I want use enum to identify type of move. Like this:
void sayTypeOfMove(int type){
switch(type){
case direction.up:
printf("IT IS UP MOVE...");
break;
}
}
The code does not compile , where is the problem?
direction.up.....:-) it's not a structure member, after all...'2', '4', '6' and '8'not2,4,6, and 8for your direction_t enums, assuming you are using a numeric keypad and getchar() or equivalent ... otherwise useswitch(direction-'0'){... sorry I just can't bring myself use type as a variable name