Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help in C

Name: Anonymous 2012-04-09 0:47

I need to execute certain commands depending on what the value of a string is. Instead of making a lot of if statements to check the string against all possible cases I thought I would hah the strings and hash the possible values for the string for which i want to do something then handle it with a switch statement. The number of different strings I'll be comparing it to is less than 100 so i dont have to worry about collisions. Is this a good idea? Do you have other ideas?

Name: Anonymous 2012-04-09 3:41

typedef struct
{
   const char cmd_str;
   void (*cmd_funct)(void *);
} cmd_t;

void assrapeop(void*)
{
  printf("not with your dick\n");
}

cmd_t cmd_array[] =
{
{ "OPIsFaggot", assrapeop},
{ 0, 0}  // null string marks the end
};

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List