Hi,
I want to assign a char pointer value to enmerated value, to use in a switch statement.
Given below is the code segment. I dont hv an idea how to convert and assign char pointer value to a enumerated value. Pls can someone help me to resolve this
enum IncomingTCPCommand
{
HEARTBEAT =0x0000,
PUBLISH =0x0001,
RETRIEVE =0x0002,
SETSTATUS =0x0003,
GETCOUNT_V1 =0x0004,
};
char * p_chArrayMessage;
char * m_p_chCommandName ;
string p_szMessage = "0x0000,set";// input string
p_chArrayMessage = new char [p_szMessage.size()+1];//copy into a char array
strcpy (p_chArrayMessage, p_szMessage.c_str());
m_p_chCommandName = strtok(p_chArrayMessage, ",");get the first token
//problem starts from here
enum IncomingTCPCommand TCPCommand = m_p_chCommandName;
m_iCommandID = (int)TCPCommand;
switch(m_iCommandID)
{
case HEARTBEAT:
//TODO case PUBLISH:
}