Your can map a word to an int, then switch is in the way.
Code:
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
void main()
{
// build command map
string commands[] = {
"east", "north", "south", "west" // ... all the command word with lower case
};
const int nCount = sizeof(commands)/sizeof(string);
// receive command from console and convert to lowercase
string strCmd;
cin >> strCmd;
for(int i=0; i<strCmd.size(); i++)
strCmd[i] = _tolower(strCmd[i]);
// map command to int
for(i=0; i<nCount; i++)
{
if(strCmd == commands[i])
break;
}
// execute command
switch(i)
{
case 0:
//do_command_east();
break;
case 1:
//do_command_north();
break;
// ...
default:
cout << "Unknow command." << endl;
}
}