You have 26 letters and 10 numbers to star with

26 char in lower and uppercase make 52

10 digits

32 other signs like `~!@#$%^&*()_+-={}|[]\:";'<>?,./

---

total of 94...

If you really want to use strings there are a few ways: (be sure to first build up the string!)

1) if then else ladder => simple and robust, slow, most used commands should be at top of the ladder of course

`if (strcmp(s, "begin")==0) `

{

}

else if (strcmp(s, "next command")==0)

{

}

else if ....

2) perfect hash function followed by a switch => fast, but not trivial to find.

`int cmd= phash(s);`

switch(cmd)

{

case 1: ..

case 2: ..

etc

}

A perfect hash is a hash function that (in this case) for every expected string of a set of commands generates an unique number by manipulating the string. It COULD look like the following:

`int phash(char *s)`

{

return (s[0]-'a')*26 + (s[1]-'a');

}

This hash function assumes that the first two chars of a command string together form an unique number [and lowercase]. It will generate a number between 0 and 625.

A perfect hash function will generate a consecutive(?) number sequence { 1,2,3,4,5,...n } for a set of commands. This makes a perfect hash quite difficult to find. One advantage of a perfect hash is that the number can be used as the index for an array of functions. ==> func[phash(commandstring)](arguments_string);

Instead of the first 2 chars one can also take the first and the last, or 3,4,5 chars or the string length, the number of vowels etc.

Drawback of hash functions is that if you add a new command your hashfunction might need a redesign, so it is often good to elaborate the completeness of the commandset first.

Hope this helps,