This is the code segment I hv written. But its compiling well. but it doest give expected output, for me..
I want to write a function to split a char array by taking "," as the delimeter.
I m not splitting the array at once. I m doing it one by one by calling the GetSection function.
char * GetSection(char **Message, char Delimeter)
{
char * Section;
*Message = strtok (*Message,",");
printf ("%s\n",*Message);
Section = *Message;
**Message = NULL;
return Section;
}
void Split(string Message)
{
unsigned int counter = 1;
char Delimeter = ',';
char * ArrayMessage;
string tempValue;
stringstream InputData;
ArrayMessage = new char [Message.size()+1];
strcpy (ArrayMessage, Message.c_str());
m_szCommandName = GetSection(&ArrayMessage, Delimeter);
printf ("%s\n",m_szCommandName);
//delete []ArrayMessage;
InputData<<command;
GetLine(InputData, m_szCommandName, MSGDELIMETER);
//convert commandName(String type) into hexadecimal format
stringstream convert ( m_szCommandName );
convert>> std::hex >> m_nCommandID;
cout<<m_nCommandID;
}