Hi All,
I need some help on ENUM in C.It would be great if I get the reply soon.
My pbm is ,I have a string for eg : data = abc".I want to convert this into int and should map with the enum value that is defined.
but when i print the result it prints as "-2......." some junk values...
I couldnt find the reason why the number is displayed.
This is how i coded ...
Code:
//defined in header file
enum Commands
{
abc = 1,
def,
ghi
}
typedef struct
{
char command[LINELEN];
char parm1[LINELEN];
} ExeCmd_s;
//main code in a function....
int temp = (int)(exeCmd.command)
switch(temp)
{
case abc : perform some operation;
break;
case def :...
....
default : break;
}
so whats the problem here and someone can help me out if possible..
Thanks,
Sowmi