I have to say, I would use words in the text file. That way the computer does more work, and the person less. Then again, my memory is prob. slowly going...
But I would convert the command string to an enum to simplify the processing (I like switch statements!)
The problems with this code are:
char x; // can only store a single char, use string instead
char y; // ditto
while (in >>x>>y) // assumes there is always a param
I would consider
- modifying the while loop so you just read the command to start with
- you then map it to an enum value using a helper function
- and then find out if the command needs a param
- if it does, read that as a string, check it's valid and then convert it (unless your comfortable with istream error handling?)
- finally use the command id and param value, if needed
This approach should make it easier to trap and handle errors.