Well there are a few ways, but all involve you doing some work.
The more obvious way is something like
Code:
enum { FILE, EDIT, VIEW };
struct {
char *name;
int value;
} table[] = {
{ "File", FILE },
( "Edit", EDIT },
{ "View", VIEW },
};
int search ( char *word ) {
// search table for matching name, returns value
}
switch ( search(word) ) {
case FILE:
break;
case EDIT:
break;
case VIEW:
break;
}
The less obvious way is to create a simple 'hash' of the keywords
Code:
#define TOK(x) ((x[0]<<24)|(x[1]<<16)|(x[2]<<8)|(x[3]))
switch ( TOK(word) ) {
case TOK("FILE"):
break;
case TOK("EDIT"):
break;
case TOK("VIEW"):
break;
}
Simple, because it must produce a compile-time constant when used in the cases.