Just working with some enumerations here
in a switch.
I thought we could use a switch as long as it was a constant and an enumeration evalutes to a constant. I keep getting a compile error here.
Im sure there are other ways this can be done but my requirements make me do it as it shows below.
Can anyone explain this compile error?
Thanks
Code:
#include<stdio.h>
#include<stdlib.h>
typedef enum {NORTH,SOUTH,EAST,WEST} direction;
int main()
{
int x=0;
int y=0;
int i;
switch (direction)
{
case NORTH:
y++;
break;
case SOUTH:
y--;
break;
case EAST:
x++;
break;
case WEST:
x--;
break;
default: x=x,y=y;
}
return 0;
}