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 ...
Re: Reg ENUM
Programming is very literal, and you don't show enough for us to tell where you might have made a mistake. You are referring to exeCmd.command, but you don't show if you have instantiated exeCmd as something of type Exe_Cmd_s. Even presuming that you have, what are you trying to do with exeCmd.command? That is a reference (essentially a pointer) to an array of char. What do you expect to get if you cast that to an int? You'll just get an int with a weird value, highly unlikely to match any of your enum values. Even if you dereferenced exeCmd.command, a match would be dependent upon how you dereferenced it and how you initialized exeCmd.command. You don't show that either.
You need to explain what you're trying to do. You need to explain how what you've done is failing to meet those expectations. You need to show all compiler or linker errors. The key to getting help and to debugging revolves around information. If you aren't using a debugger, then toss in some output statements to give you feedback. Turn on all errors and warnings, if you haven't.
Remember that you are sitting in your chair looking at your code. We are not. You have to tell us what's what. Present a small, but complete, snippet that reproduces the problem.
Read the entire "Before you make a query" thread.
Re: Reg ENUM
Oh..You are right!!..I could have given the complete information so that it would be easy for others.
Apologize of the same.
Will explain i detail inmy next message.
|All times are GMT +5.5. The time now is 03:15.|