enum with case , switch statment in c

Status
Not open for further replies.

Parth86

Member
Hello
I have written original code for three task's. Now I want do one by one in program. I found on internet that I have to use enum case and switch statement in program. Look at below program it's hand made program just for understanding. I understand the case and switch statement in program. I don't understand what does enum do in program and use of enum in program
C:
typedef enum
{
task_1 =0,
task_2,
task_3
}my_state_t;
my_task_t task = task_1;

int main ()
{
unsigned int task;
switch(task)
{
case 1:
if my_task_t task = task_1
Do task 1 ();
break;
case 2:
if my_task_t task = task_2
Do task 2 ();
Break;
case 3:
my_task_t task = task_3
Do task 3 ( );
}
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…