Is the included code even close to what you guys are suggestong? Could post a small snippet showing your solution?
Code:
#include <string.h>
#include <stdio.h>
#define MAX_ACTIONS 2
void CheckForAction(char message[80]);
int main(void)
{
char message[] ="/wave", message1[] = "/whisper User_2";
CheckForAction(message1);
getchar();
return (0);
}
void CheckForAction(char message[80])
{
char *action[MAX_ACTIONS] = {"/wave", "/whisper"};
char temp[2][100] = {{""},{""}};
char *ptr = NULL;
ptr = strtok(message, " ");
strcpy(temp[0],ptr);
ptr = strtok(NULL," ");
if(ptr != NULL)
strcpy(temp[1],ptr);
if(strcmp(temp[0], "/wave") == 0)
printf("%s waves to everyone\n", "User_1");
if(strcmp(temp[0], "/whisper") == 0 && strcmp(temp[1],"") == 0)
printf("%s whispers to the crowd\n", "User_1");
else
printf("%s whispers to %s\n", "User_1", temp[1]);
}