• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

EE World Online Articles

Loading
Top